最近同事找了一个keras代码,要run下,今天配置了下环境。
- Windows 11 专业版 21H2 22000.795
- Quadro RTX 6000
- NVCUDA64.dll 31.0.15.1694 NVDIA CUDA 11.7.101 driver
- 显卡驱动版本:516.94
1、安装python
我这里用的是miniconda,创建了一个虚环境myann,python的版本是3.10.4
conda create -n myann
conda activate myann
2、切换镜像源到清华大学
编辑 C:\Users\用户\xxx\pip\pip.ini
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
3、安装相关包
pip install tensorflow
pip install scipy
pip install matplotlib
pip install obspy
这里安装的tensorflow的版本是2.9.1
这步后,程序已经运行,但启用的是cpu计算,要开启GPU,还需要继续配置。
安装文件如图所示
4、安装 NVIDIA GPU Computing Toolkit
CUDA Toolkit Archive | NVIDIA Developer
下载 CUDA ToolKit 11.7.1
ok后直接安装
5、安装cuDNN
cuDNN Archive | NVIDIA Developer
版本v8.4.0 for CUDA 11.x
解压到C:\tools\cuda
6、下载Zlib
Installation Guide :: NVIDIA Deep Learning cuDNN Documentation
这里只需要用到一个zlibwapi.dll,复制到C:\tools\cuda\bin
7、配置环境变量
8、OK,运行下试试
2022-08-04 17:42:23.619207: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-08-04 17:42:24.519418: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1532] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 22178 MB memory: -> device: 0, name: Quadro RTX 6000, pci bus id: 0000:2d:00.0, compute capability: 7.5
Deploying 0/3-th subcube
2022-08-04 17:42:30.775587: I tensorflow/stream_executor/cuda/cuda_dnn.cc:384] Loaded cuDNN version 8401
Deploying 1/3-th subcube
Deploying 2/3-th subcube
运行后,成功启用GPU计算,运行速度是CPU的10倍。