Ubuntu18下部署TensorFlow2.5.2

文章详细介绍了如何在Ubuntu18上通过Anaconda创建并激活虚拟环境,然后在该环境中安装Python3.7和TensorFlow2.5.2。虽然安装成功,但在测试时显示出可能未配置GPU支持的警告。

安装anaconda

https://repo.anaconda.com/archive/Anaconda2-2019.10-Linux-x86_64.sh下载Anaconda安装程序,并上传到Ubuntu的目录下。

sh Anaconda3-2019.10-Linux-x86_64.sh

根据提示信息进行Anaconda的安装。

创建虚拟环境

conda create -n tf_env python=3.7

激活虚拟环境

(base) jihui@jihui-vm:~$ conda activate tf_env
(tf_env) jihui@jihui-vm:~$ python
Python 3.7.13 (default, Mar 29 2022, 02:18:16) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
(tf_env) jihui@jihui-vm:~$ 

安装Tensorflow 2.5.2

(tf_env) jihui@jihui-vm:~$ pip install tensorflow==2.5.2 -i https://mirrors.aliyun.com/pypi/simple/
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting tensorflow==2.5.2
  Downloading https://mirrors.aliyun.com/pypi/packages/5f/4d/b675803c25feca2e1a896c2c38380db4d9477d8ce4bd58ea103837793527/tensorflow-2.5.2-cp37-cp37m-manylinux2010_x86_64.whl (454.4 MB)
     ╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.2/454.4 MB 325.7 kB/s eta 0:22:54

测试安装结果

(tf_env) jihui@jihui-vm:~$ python
Python 3.7.13 (default, Mar 29 2022, 02:18:16) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2023-03-07 18:11:43.298025: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2023-03-07 18:11:43.298230: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
>>> print(tf.__version__)
2.5.2
>>> 

退出虚拟环境

(tf_env) jihui@jihui-vm:~$ conda deactivate
(base) jihui@jihui-vm:~$ 

说明

安装Tensorflow 2.X一定要注意Python的版本,使用Ubuntu 18自带的Python3.6,在安装时会显示没有Tensorflow2,只能安装Tensorflow 1.X。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值