tensorflow2.x使用cuda10.2(非常简单)

# 目前tensorflow2.2官方标配cuda10.1,也是官方在github给出方案,修改cuda软链接即可,非常简单。也不影响pytorch1.5(cuda10.2)的继续使用。

# 前提是你已经正确安装cuda10.2,检查:
nvidia-smi
nvcc -V

# 干正事(重点就这二步):
cd /usr/local/cuda-10.2/targets/x86_64-linux/lib/
ln -s libcudart.so.10.2.89 libcudart.so.10.1

cd /usr/local/cuda-10.2/extras/CUPTI/lib64
ln -s libcupti.so.10.2.75 libcupti.so.10.1

# 检查添加路径:
vim /etc/profile
export CUDA_HOME=/usr/local/cuda-10.2
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${CUDA_HOME}/extras/CUPTI/lib64
export PATH=${CUDA_HOME}/bin:${PATH}
source /etc/profile

# 检查GPU:
>python
>>>import tensorflow as tf
>>>tf.__version__
2.2.0
>>>tf.test.is_gpu_available()
True
>>>tf.config.list_physical_devices('GPU')
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU'),
 PhysicalDevice(name='/physical_device:GPU:1', device_type='GPU'),
 PhysicalDevice(name='/physical_device:GPU:2', device_type='GPU'),
 PhysicalDevice(name='/physical_device:GPU:3', device_type='GPU')]

大功告成!

你可能感兴趣的:(Linux,ML,python)