Tensorflow 安装(GPU)anaconda3环境Ubuntu20

确保网速!!!网速不行直接不行,有一个包一直下下载失败:tensorflow-base-2.2.0(大小187M)

conda install tensorflow-gpu

 自动配置环境,提示需要下载的包,输入yes或y开始下载

安装成功!下载失败没问题,可能是网络问题,换个好点的网络,重新 conda install tensorflow-gpu ,他会自动检查需要安装的包。

测试一下:


import tensorflow as tf

import os
from tensorflow.python.client import device_lib

os.environ["TF_CPP_MIN_LOG_LEVEL"] = "99"

if __name__ == "__main__":
    print(device_lib.list_local_devices())

运行结果:

home/wangwensong/anaconda3/bin/python /home/wangwensong/PycharmProjects/Test_tensorflow/test_tensorflow_CPU.py
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 6564364605466115649
, name: "/device:XLA_CPU:0"
device_type: "XLA_CPU"
memory_limit: 17179869184
locality {
}
incarnation: 12704223918485953344
physical_device_desc: "device: XLA_CPU device"
]

Process finished with exit code 0

!!!提示我的是CPU....

但是查看安装tensorflow-gpu 的时候自动下载了CUDA、CUDNN、tensorflow,所以可能是驱动问题

查看一下

nvidia-smi

果然没有....

安装nvidia-driver-440版本驱动为例,安装只需要下面一条命令就可以:

sudo apt install nvidia-driver-440

安装完需要重启系统才能生效,太吓人了....重启系统还顺便更新了firmware.....

你可能感兴趣的:(TensorFlow)