tensorflow2.x使用cuda10.2(非常简单)

36 篇文章 0 订阅
7 篇文章 0 订阅
# 目前tensorflow2.2/2.3官方标配cuda10.1,也是官方在github给出方案,修改cuda软链接即可,非常简单。也不影响pytorch1.5(cuda10.2)的继续使用。

# 前提是你已经正确安装cuda10.2,检查:
nvidia-smi
nvcc -V

# 干正事(重点就这二步):
cd /usr/local/cuda-10.2/targets/x86_64-linux/lib/
ln -s libcudart.so.10.2.89 libcudart.so.10.1

cd /usr/local/cuda-10.2/extras/CUPTI/lib64
ln -s libcupti.so.10.2.75 libcupti.so.10.1

# 检查添加路径:
vim /etc/profile
export CUDA_HOME=/usr/local/cuda-10.2
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${CUDA_HOME}/extras/CUPTI/lib64
export PATH=${CUDA_HOME}/bin:${PATH}
source /etc/profile

# 检查GPU:
>python
>>>import tensorflow as tf
>>>tf.__version__
2.2.0
>>>tf.test.is_gpu_available()
True
>>>tf.config.list_physical_devices('GPU')
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU'),
 PhysicalDevice(name='/physical_device:GPU:1', device_type='GPU'),
 PhysicalDevice(name='/physical_device:GPU:2', device_type='GPU'),
 PhysicalDevice(name='/physical_device:GPU:3', device_type='GPU')]

大功告成!

nohup python train_tf_model.py > log.txt 2>&1 &
watch -n 0.1 -d nvidia-smi # linux,每隔0.1秒刷新一次
nvidia-smi -l 0.1 # windows命令行
tailf log.txt

tensorboard --logdir=callbacks --host=xxx.xx.xxx.xx # 服务器地址
自编译tensorflow: 1.python3.5,tensorflow1.12; 2.支持cuda10.0,cudnn7.3.1,TensorRT-5.0.2.6-cuda10.0-cudnn7.3; 3.无mkl支持; 软硬件硬件环境:Ubuntu16.04,GeForce GTX 1080 TI 配置信息: hp@dla:~/work/ts_compile/tensorflow$ ./configure WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown". You have bazel 0.19.1 installed. Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3 Found possible Python library paths: /usr/local/lib/python3.5/dist-packages /usr/lib/python3/dist-packages Please input the desired Python library path to use. Default is [/usr/local/lib/python3.5/dist-packages] Do you wish to build TensorFlow with XLA JIT support? [Y/n]: XLA JIT support will be enabled for TensorFlow. Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: No OpenCL SYCL support will be enabled for TensorFlow. Do you wish to build TensorFlow with ROCm support? [y/N]: No ROCm support will be enabled for TensorFlow. Do you wish to build TensorFlow with CUDA support? [y/N]: y CUDA support will be enabled for TensorFlow. Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10.0]: Please specify the location where CUDA 10.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda-10.0 Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]: 7.3.1 Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda-10.0]: Do you wish to build TensorFlow with TensorRT support? [y/N]: y TensorRT support will be enabled for TensorFlow. Please specify the location where TensorRT is installed. [Default is /usr/lib/x86_64-linux-gnu]://home/hp/bin/TensorRT-5.0.2.6-cuda10.0-cudnn7.3/targets/x86_64-linux-gnu Please specify the locally installed NCCL version you want to use. [Default is to use https://github.com/nvidia/nccl]: Please specify a list of comma-separated Cuda compute capabilities you want to build with. You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus. Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 6.1,6.1,6.1]: Do you want to use clang as CUDA compiler? [y/N]: nvcc will be used as CUDA compiler. Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: Do you wish to build TensorFlow with MPI support? [y/N]: No MPI support will be enabled for TensorFlow. Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]: Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: Not configuring the WORKSPACE for Android builds. Preconfigured Bazel build configs. You can use any of the below by adding "--config=" to your build command. See .bazelrc for more details. --config=mkl # Build with MKL support. --config=monolithic # Config for mostly static monolithic build. --config=gdr # Build with GDR support. --config=verbs # Build with libverbs support. --config=ngraph # Build with Intel nGraph support. --config=dynamic_kernels # (Experimental) Build kernels into separate shared objects. Preconfigured Bazel build configs to DISABLE default on features: --config=noaws # Disable AWS S3 filesystem support. --config=nogcp # Disable GCP support. --config=nohdfs # Disable HDFS support. --config=noignite # Disable Apacha Ignite support. --config=nokafka # Disable Apache Kafka support. --config=nonccl # Disable NVIDIA NCCL support. Configuration finished 编译: bazel build --config=opt --verbose_failures //tensorflow/tools/pip_package:build_pip_package 卸载已有tensorflow: hp@dla:~/temp$ sudo pip3 uninstall tensorflow 安装自己编译的成果: hp@dla:~/temp$ sudo pip3 install tensorflow-1.12.0-cp35-cp35m-linux_x86_64.whl
### 回答1: `b'cuda10.2\xe5\xaf\xb9\xe5\xba\x94\xe7\x9a\x84tensorflow\xe7\x89\x88\xe6\x9c\xac'` 的意思是:支持 CUDA10.2TensorFlow 版本。 ### 回答2: CUDA(Compute Unified Device Architecture)是由NVIDIA推出的GPU编程平台,其目的是提高GPU运算效率从而加速计算。在深度学习及其相关领域中,有许多流行的深度学习框架,需要结合CUDA进行实现,其中最重要的框架之一就是TensorFlowTensorFlow是由Google开发的一个开源深度学习框架,它支持Python、Java等多种编程语言,而且广泛应用于科学计算、机器学习等方面。在TensorFlow中,需要事先安装适合的CUDA版本,以保证TensorFlow能够与CUDA兼容,从而提高运算效率。 针对此问题,目前,tensorflow-gpu 2.3.0可以兼容CUDA 10.2。因此,如果需要在CUDA 10.2平台上使用TensorFlow,可以通过以下命令安装: ``` pip install tensorflow-gpu==2.3.0 ``` 需要注意的是,安装之前应先确认CUDA 10.2已经正确安装,并注意TensorFlow的版本兼容。如果未安装合适的CUDA版本,则会导致TensorFlow的不兼容或出现错误信息。 总之,TensorFlowCUDA是紧密相关的。要充分利用GPU的算力优势,正确选择适合的TensorFlow版本和CUDA版本并且进行正确的安装是至关重要的。 ### 回答3: CUDA 10.2是由NVIDIA发布的一款GPU计算平台,它提供了强大的加速和优化功能,可以充分利用英伟达GPU的并行计算能力。而TensorFlow是Google开源的一款人工智能开发框架,为深度学习和机器学习带来了极大的便利性和效率。许多开发者都希望知道CUDA10.2对应的TensorFlow版本是什么。接下来,我将详细介绍一下。 首先,要知道CUDATensorFlow之间的版本兼容关系。它们之间的关系通常是:每一个TensorFlow版本都有特定的兼容性CUDA版本,这是由TensorFlow开发团队和NVIDIA协同决定的。因此,使用正确的TensorFlow版本是至关重要的,它能够为您提供最好的性能和体验。 在实践中,如果您使用的是CUDA 10.2,那么您需要选择兼容的TensorFlow版本。TensorFlow的最新版本(截至2021年8月)是版本2.6.0,它支持CUDA 11.2,cuda11.1和cuda10.1三种版本。而您想要使用CUDA 10.2,那么您需要选择一些较旧的TensorFlow版本,例如TensorFlow2.1,TensorFlow2.2,TensorFlow2.3,TensorFlow2.4等。这些版本因为与CUDA 10.2具有兼容性,因此可以使用CUDA 10.2进行GPU加速。 总的来说,TensorFlowCUDA之间的版本兼容性需要仔细考虑。如果您使用的是CUDA 10.2,则需要选择与之兼容的TensorFlow版本,以确保能够正确、高效地运行您的深度学习项目。
评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值