win10+anaconda虚拟环境安装tensorflow-gpu步骤
安装anaconda3,版本稳定,python3.7.3
对应关系tensorflow-gpu2.1.0+cuDNN7.4+CUDA10.1
由于之前安装的CUDA是10.2的现在重新安装太麻烦就直接改版本号
方法:
1、将CUDA安装目录下的 D:\cudnn-10.2-windows10-x64-v7.6.5.32\cuda\bin\cudart64_102.dll 在所在目录下复制一份,更名为cudart64_101.dll
2、将CUDA安装目录下的(已经安装好cuDNN了)E:\cuda\v10.2\cudnn\bin\cudnn64_8,复制一份到E:\cuda\v10.2\bin目录下,并更名为cudnn64_7.dll
创建虚拟环境
conda create -n tensorflow-gpu python==3.7
激活虚拟环境
activate tensorflow-gpu
安装tensorflow (如果有GPU此步可不用安装)
conda install tensorflow==2.1.0
安装tensorflow-gpu
conda install tensorflow-gpu==2.1.0
安装完毕,测试gpu是否成功:
import tensorflow as tf
测试:
import tensorflow as tf
print(tf.test.is_gpu_available())
2023-11-23 09:55:43.709821: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
WARNING:tensorflow:From <input>:2: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2023-11-23 09:55:46.594352: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2023-11-23 09:55:46.598213: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2023-11-23 09:55:46.646740: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1650 with Max-Q Design computeCapability: 7.5
coreClock: 1.35GHz coreCount: 14 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 149.04GiB/s
2023-11-23 09:55:46.647068: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2023-11-23 09:55:47.214442: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2023-11-23 09:55:47.307430: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2023-11-23 09:55:47.349768: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2023-11-23 09:55:47.685856: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2023-11-23 09:55:48.018950: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2023-11-23 09:55:48.355869: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2023-11-23 09:55:48.356109: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2023-11-23 09:55:50.484168: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2023-11-23 09:55:50.484315: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] 0
2023-11-23 09:55:50.484413: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0: N
2023-11-23 09:55:50.485025: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/device:GPU:0 with 2919 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1650 with Max-Q Design, pci bus id: 0000:01:00.0, compute capability: 7.5)
True
返回True