之前一直使用的1080的显卡,最近换成3090的显卡,跑tensorflow的程序,发现没办法使用GPU,只能在CPU上面跑。
之后开始尝试各种装环境,遇到各种不兼容不匹配。
第一次成功使用GPU加速,但是遇到了网络输出全是nan的问题,排除掉所有可能存在问题的地方,最终发现还是环境没有配置好。
受https://blog.csdn.net/ALZFterry/article/details/116063978这篇博客的启发,第一次装了tensorflow-gpu=2.5,偶然之间发现可以使用gpu运行了。
最主要的几个安装包的版本如下所示:
tensorflow-gpu==2.5.0
cudnn=8.4.1.50=hed8a83a_0
cudatoolkit=11.0.221=h6bb024c_0
python=3.7.13=h12debd9_0
这是运行的结果,一个epoch大概2分钟。使用CPU跑的话,一个epoch大概需要140分钟
下面附上我的环境的requirements
使用以下命令可以创建出一模一样的环境:
conda env create -f requirements.yml
requirements.yml
name: E2E
channels:
- defaults
- conda-forge
dependencies:
- _libgcc_mutex=0.1=conda_forge
- _openmp_mutex=4.5=2_kmp_llvm
- cudnn=8.4.1.50=hed8a83a_0
- libgcc-ng=12.1.0=h8d9b700_16
- libstdcxx-ng=12.1.0=ha89aaad_16
- libzlib=1.2.12=h166bdaf_1
- llvm-openmp=14.0.4=he0ac6c6_0
- zlib=1.2.12=h166bdaf_1
- ca-certificates=2022.4.26=h06a4308_0
- certifi=2022.6.15=py37h06a4308_0
- cudatoolkit=11.0.221=h6bb024c_0
- ld_impl_linux-64=2.38=h1181459_1
- libffi=3.3=he6710b0_2
- ncurses=6.3=h5eee18b_3
- openssl=1.1.1p=h5eee18b_0
- pip=21.2.2=py37h06a4308_0
- python=3.7.13=h12debd9_0
- readline=8.1.2=h7f8727e_1
- setuptools=61.2.0=py37h06a4308_0
- sqlite=3.38.5=hc218d9a_0
- tk=8.6.12=h1ccaba5_0
- wheel=0.37.1=pyhd3eb1b0_0
- xz=5.2.5=h7f8727e_1
- pip:
- absl-py==0.15.0
- astunparse==1.6.3
- cached-property==1.5.2
- cachetools==5.2.0
- charset-normalizer==2.1.0
- dill==0.3.5.1
- etils==0.6.0
- flatbuffers==1.12
- gast==0.4.0
- google-auth==2.9.0
- google-auth-oauthlib==0.4.6
- google-pasta==0.2.0
- googleapis-common-protos==1.56.3
- grpcio==1.34.1
- h5py==3.1.0
- idna==3.3
- importlib-metadata==4.12.0
- importlib-resources==5.8.0
- keras==2.8.0
- keras-nightly==2.5.0.dev2021032900
- keras-preprocessing==1.1.2
- libclang==14.0.1
- markdown==3.3.7
- numpy==1.19.5
- oauthlib==3.2.0
- opt-einsum==3.3.0
- packaging==21.3
- promise==2.3
- protobuf==3.20.1
- pyasn1==0.4.8
- pyasn1-modules==0.2.8
- pyparsing==3.0.9
- requests==2.28.1
- requests-oauthlib==1.3.1
- rsa==4.8
- six==1.15.0
- tensorboard==2.8.0
- tensorboard-data-server==0.6.1
- tensorboard-plugin-wit==1.8.1
- tensorflow-addons==0.17.1
- tensorflow-datasets==4.6.0
- tensorflow-estimator==2.5.0
- tensorflow-gpu==2.5.0
- tensorflow-io-gcs-filesystem==0.26.0
- tensorflow-metadata==1.9.0
- termcolor==1.1.0
- toml==0.10.2
- tqdm==4.64.0
- typeguard==2.13.3
- typing-extensions==3.7.4.3
- urllib3==1.26.9
- werkzeug==2.1.2
- wrapt==1.12.1
- zipp==3.8.0
prefix: /home/ljh/anaconda3/envs/E2E