Ubuntu 18.04 配置 tensorflow-gpu 机器学习环境
2022/3/10 7:15:57
本文主要是介绍Ubuntu 18.04 配置 tensorflow-gpu 机器学习环境,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1. 安装python 3.7
sudo apt install python3.7 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2 %python3 指向 python 3.7 sudo update-alternatives --config python3 % if multiple python3 exists, enter the default number such as 2 in this case %install the pip3 sudo apt update curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py sudo apt install python3-distutils sudo python3.7 get-pip.py sudo ln -s /usr/local/bin/pip3.7 /usr/bin/pip3 %install tensorflow-gpu 2.6.0 keras 2.6.0 pip3 install tensorflow-gpu==2.6.0 pip3 install keras==2.6.0
2. 安装cuda
nvidia-smi % to find the version of cuda supported wget https://developer.download.nvidia.com/compute/cuda/11.2.1/local_installers/cuda_11.2.1_460.32.03_linux.run %cuda11.2 is chosen sudo apt install build-essential % to run the file, gcc, g++ should be installed sudo sh cuda_11.2.1_460.32.03_linux.run % install cuda, remember not to install driver in the options %edit the environment sudo vim ~/.bashrc export PATH=/usr/local/cuda-11.2/bin:/usr/local/cuda-11.2/nsight-compute-2021.3.4${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64\ ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} source ~/.bashrc cd usr/local/cuda-11.2/samples/1_Utilities/deviceQuery sudo make ./deviceQuery nvcc -V %to show the version of cuda
3 安装cudnn
wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.1.0.77/11.2_20210127/cudnn-11.2-linux-x64-v8.1.0.77.tgz tar -zxf cudnn-11.2-linux-x64-v8.1.0.77.tgz cd cuda sudo cp cuda/include/cudnn.h /usr/local/cuda-11.2/include sudo cp cuda/lib64/libcudnn* /usr/local/cuda-11.2/lib64 sudo chmod a+r /usr/local/cuda-11.2/include/cudnn.h sudo chmod a+r /usr/local/cuda-11.2/lib64/libcudnn*
4. 测试
import tensorflow print(tf.test.is_gpu_available()) %if True is printed, gpu is available
这篇关于Ubuntu 18.04 配置 tensorflow-gpu 机器学习环境的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-30tensorflow是什么-icode9专业技术文章分享
- 2024-10-15成功地使用本地的 NVIDIA GPU 运行 PyTorch 或 TensorFlow
- 2024-01-23供应链投毒预警 | 恶意Py包仿冒tensorflow AI框架实施后门投毒攻击
- 2024-01-19attributeerror: module 'tensorflow' has no attribute 'placeholder'
- 2024-01-19module 'tensorflow.compat.v2' has no attribute 'internal'
- 2023-07-17【2023年】第33天 Neural Networks and Deep Learning with TensorFlow
- 2023-07-10【2023年】第32天 Boosted Trees with TensorFlow 2.0(随机森林)
- 2023-07-09【2023年】第31天 Logistic Regression with TensorFlow 2.0(用TensorFlow进行逻辑回归)
- 2023-07-01【2023年】第30天 Supervised Learning with TensorFlow 2(用TensorFlow进行监督学习 2)
- 2023-06-18【2023年】第29天 Supervised Learning with TensorFlow 1(用TensorFlow进行监督学习 1)