tensorflow-gpu 2.4.0 安装

1. 安装cuda

 (1)没有sudo命令

su -

yum install sudo

(2)没有wget命令

sudo yum install wget

 (3)安装cuda11.0

wget http://developer.download.nvidia.com/compute/cuda/11.0.2/local_installers/cuda_11.0.2_450.51.05_linux.run

sudo sh cuda_11.0.2_450.51.05_linux.run

 注意,这里按回车取消勾选driver:

 然后选择Install。

但给出如下日志:

===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-11.0/
Samples:  Installed in /root/, but missing recommended libraries

Please make sure that
 -   PATH includes /usr/local/cuda-11.0/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-11.0/lib64, or, add /usr/local/cuda-11.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.0/bin

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-11.0/doc/pdf for detailed information on setting up CUDA.
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least .00 is required for CUDA 11.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run --silent --driver

Logfile is /var/log/cuda-installer.log

此时修改环境变量:

vim ~/.bashrc 

进入以后输入:

export PATH=/usr/local/cuda-11.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

这里一定要输入$后面的,不然会覆盖原有的PATH变量。

出来后输入:

 source ~/.bashrc

 此时输入:nvcc -V测试一下,应当显示安装成功:

2. 安装cudnn8.0

(1)官网(cuDNN Archive | NVIDIA Developer)下载:我下载的cuDNN v8.0.5 for CUDA11.0

(2)

tar -xzvf cudnn-11.0-linux-x64-v8.0.5.39.tgz -C /root # -C后跟要保存的目录

# 注意,/root/cuda是cudnn目录,/usr/local/cuda是cuda的目录
(venv-kdfast) [root@0f518f45dc79 cuda] sudo cp /root/cuda/include/cudnn*.h /usr/local/cuda/include
(venv-kdfast) [root@0f518f45dc79 cuda] sudo cp /root/cuda/lib64/libcudnn* /usr/local/cuda/lib64
(venv-kdfast) [root@0f518f45dc79 cuda] sudo chmod a+r /usr/local/cuda/include/cudnn*.h
(venv-kdfast) [root@0f518f45dc79 cuda] sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

 (3)测试一下:cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

如果成功,应当显示:

#define CUDNN_MAJOR 8
#define CUDNN_MINOR 0
#define CUDNN_PATCHLEVEL 5
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

#endif /* CUDNN_VERSION_H */

 最后,测试一下tensorflow:

>>> import tensorflow as tf
2023-07-19 15:27:48.291353: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
>>> tf.test.is_gpu_available(
... )
WARNING:tensorflow:From <stdin>:1: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2023-07-19 15:27:57.989208: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX512F
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-07-19 15:27:58.000793: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
2023-07-19 15:27:58.001899: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2023-07-19 15:27:58.429787: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:3b:00.0 name: GeForce RTX 3090 computeCapability: 8.6
coreClock: 1.695GHz coreCount: 82 deviceMemorySize: 23.70GiB deviceMemoryBandwidth: 871.81GiB/s
2023-07-19 15:27:58.431068: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 1 with properties:
pciBusID: 0000:af:00.0 name: GeForce RTX 3090 computeCapability: 8.6
coreClock: 1.695GHz coreCount: 82 deviceMemorySize: 23.70GiB deviceMemoryBandwidth: 871.81GiB/s
2023-07-19 15:27:58.432032: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 2 with properties:
pciBusID: 0000:d8:00.0 name: GeForce RTX 3090 computeCapability: 8.6
coreClock: 1.695GHz coreCount: 82 deviceMemorySize: 23.70GiB deviceMemoryBandwidth: 871.81GiB/s
2023-07-19 15:27:58.432133: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2023-07-19 15:27:58.435234: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.11
2023-07-19 15:27:58.435324: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.11
2023-07-19 15:27:58.436859: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2023-07-19 15:27:58.437224: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2023-07-19 15:27:58.441241: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10
2023-07-19 15:27:58.442235: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.11
2023-07-19 15:27:58.442442: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.8
2023-07-19 15:27:58.447471: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0, 1, 2
2023-07-19 15:27:58.447514: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2023-07-19 15:28:00.726430: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2023-07-19 15:28:00.726501: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267]      0 1 2
2023-07-19 15:28:00.726512: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0:   N N N
2023-07-19 15:28:00.726520: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 1:   N N N
2023-07-19 15:28:00.726527: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 2:   N N N
2023-07-19 15:28:00.730421: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/device:GPU:0 with 14343 MB memory) -> physical GPU (device: 0, name: GeForce RTX 3090, pci bus id: 0000:3b:00.0, compute capability: 8.6)
2023-07-19 15:28:00.732704: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/device:GPU:1 with 22428 MB memory) -> physical GPU (device: 1, name: GeForce RTX 3090, pci bus id: 0000:af:00.0, compute capability: 8.6)
2023-07-19 15:28:00.734959: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/device:GPU:2 with 18690 MB memory) -> physical GPU (device: 2, name: GeForce RTX 3090, pci bus id: 0000:d8:00.0, compute capability: 8.6)
True

成功!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据引用内容,安装Tensorflow-GPU2.4.0的步骤如下: 1. 首先,确保你已经安装Python3和虚拟环境包virtualenv和virtualenvwrapper。可以使用以下命令安装Python3: ``` sudo apt-get update sudo apt-get install python3 ``` 安装虚拟环境包可以使用以下命令: ``` sudo apt-get install virtualenv virtualenvwrapper ``` 2. 接下来,你需要安装CUDA驱动。可以使用以下命令下载CUDA驱动安装包: ``` sudo sh cuda_11.2.0_460.27.04_linux.run ``` 如果无法运行该命令,可以尝试使用以下命令提权: ``` chmod -R 777 cuda_11.2.0_460.27.04_linux.run ``` 在安装过程中,如果已经安装了显卡驱动,需要取消Driver选项,然后选择Install安装。 3. 安装完成后,你可以使用以下命令安装Tensorflow-GPU2.4.0: ``` pip install tensorflow-gpu==2.4.0 ``` 注意,确保你的Python版本是3.8.7,因为Tensorflow-GPU2.4.0与该版本兼容。 这样,你就可以在Ubuntu20.04上成功安装Tensorflow-GPU2.4.0了。希望对你有帮助!\[1\]\[2\]\[3\] #### 引用[.reference_title] - *1* *2* [Win10环境下安装Python3及Tensorflow2.4.0-GPU配置](https://blog.csdn.net/weixin_45012228/article/details/115895648)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [RTX3090+Ubuntu 20.04+tensorflow 2.4.0安装指南](https://blog.csdn.net/AiBigData/article/details/112855741)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值