问题1
>>> import tensorflow as tf
2023-05-31 10:50:34.908411: 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: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-05-31 10:50:35.606378: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2023-05-31 10:50:35.606460: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2023-05-31 10:50:35.606470: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
>>> tf.config.list_physical_devices('GPU')
2023-05-31 10:50:56.688374: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudnn.so.8'; dlerror: libcudnn.so.8: cannot open shared object file: No such file or directory
2023-05-31 10:50:56.688462: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1934] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
解决方案(跟着走)
问题2 (还未解决)
解决 and 终极安装
- note: 要正确选择 cudatoolkit、 cudnn(conda安装就是cudnn,pip安装叫nvidia-cudnn-cu11)和 tensorflow的版本组合,有不少组合并不可用,尽管满足tensorflow给出的对应关系。
- 经实验可用的组合有:
- py3.8+tf2.9+cuda11.3.1+cudnn8.2.1
- py3.8+tf2.9+cuda11.6+cudnn8.6
- 安装步骤依旧按照tensorflow官网:https://www.tensorflow.org/install/pip 。其中安装cudatoolkit, cudnn, tensorflow需要改(用conda 或者 pip,conda官方的源还是清华的源,还得看清华的源有没有该版本资源)
- 我安装上述三个组件的指令:
- conda install cudatoolkit=11.3.1
- conda install cudnn=8.2.1 (没有在pip找到该版本)
- pip install tensorflow==2.9.*
- ubuntu22.04 需要额外一步