GPU-Tensorflow-linux
参考:
1.Linux conda中Tensorflow GPU安装配置全面梳理(包含cuda、cudnn)_gv102-CSDN博客
2. Tensorflow-GPU和sklearn的安装_怎么在tensorflow里面安装sklearn-CSDN博客
明明很简单但搞了半天 总结个有用的教程叭
- 确认GPU 显卡
lspci | grep -i vga
第一行是集成显卡,忽略 - 确定TensorFlow版本 python3.9对应的是2.6.0
- 创建环境
- conda create -n yourname python=3.9 # 创建虚拟环境,python选择3.9
- activate yourname -gpu # 激活虚拟环境
- 安装
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
(两个分开装可能报错 这个指令亲测有效) pip install matplotlib==3.5.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install numpy==1.19.5 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install scikit-learn==0.24.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install tensorflow-gpu==2.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install protobuf==3.20.0 -i https://pypi.tuna.tsinghua.edu.cn/simple # protobuf需要满足版本大于3.19.6且不超过3.20.x
pip install keras==2.6 -i https://pypi.tuna.tsinghua.edu.cn/simple
- 检测
--coding: utf8--
import tensorflow as tf
if __name__ == '__main__':
print('tf version: {}'.format(tf.__version__))
print('keras version: {}'.format(tf.keras.__version__))
# print('GPU: {}'.format(tf.test.is_gpu_available())) # 1.x版本的TF使用此行
print('GPU: {}'.format(tf.config.list_physical_devices('GPU'))) # 2.x版本的TF使用
GPU-pytorch-windows
Windows
成功解决:AssertionError: Torch not compiled with CUDA enabled-CSDN博客
其他
24.01.07 | 计算机视觉博士生存指南(三) | 服务器配置与基础Linux指令大全 - 知乎 (zhihu.com)