windows10-cuda10.1-cudnn7-tensorflow1.4.0配置流程

1.下载cuda版本:cuda_10.1.105_win10_network.exe,并按照流程安装。安装完后,打开cmd ,输入:nvcc -V,回车查看是否有版本信息,若出现版本信息,则证明nvcc安装成功。

2.下载cudnn版本:cudnn-10.0-windows10-x64-v7.4.2.24,并把bin,include,lib三个文件拷贝到CUDA/10.1文件夹中。

3.下载Anaconda3-5.2.0-Windows-x86_64.exe版本,并按照流程在windows中安装,安装的路径可以自己选择,我安装的路径为

D:\ProgramData\Anaconda3 。

4.利用anaconda来创建python3.6.5的虚拟环境:conda create  -n tensorflow-gpu python=3.6.5,并打开Anaconda Navigator ,可以看到创建的tensorflow-gpu虚拟环境

5.激活虚拟环境:在Anaconda prompt 中输入 activate tensorflow-gpu ,环境从base中跳到虚拟环境中,如下图:

6.安装tensorflow-gpu版本:pip install tensorflow-gpu==1.4.0

7.测试,python  import tensorflow as tf

 

自编译tensorflow1.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
### 安装 TensorFlow 的方法 要在 Anaconda 的 Jupyter Notebook 环境中安装并使用 TensorFlow,可以按照以下方式操作: #### 创建虚拟环境 为了确保兼容性和隔离性,建议先创建一个新的 Conda 虚拟环境,并指定 Python 版本。例如,可以选择 Python 3.7 作为基础版本: ```bash conda create -n tensorflow python=3.7 [^1] ``` 激活该虚拟环境: ```bash conda activate tensorflow ``` #### 安装 TensorFlow 根据需求选择 CPU 或 GPU 版本TensorFlow。 对于 **CPU 版本**,可以直接通过 `pip` 进行安装: ```bash pip install tensorflow==1.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple [^2] ``` 如果需要支持 GPU 加速,则需额外配置 CUDA 工具包以及 cuDNN 库。可以通过以下命令完成安装: ```bash conda install cudatoolkit=10.1 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/ [^4] ``` 随后再安装对应的 GPU 支持版 TensorFlow(注意替换具体版本号以匹配 CUDA 配置)。 #### 测试安装是否成功 进入 Jupyter Notebook 后,在单元格内运行如下代码验证 TensorFlow 是否正常工作: ```python import tensorflow as tf print(tf.__version__) [^3] ``` 若能正确打印出版本信息则表明安装无误。 另外,在实际编写模型训练脚本时可能需要用到会话机制(Session),此时可通过下面的方式初始化全局变量并执行计算图中的节点运算: ```python init = tf.global_variables_initializer() with tf.Session() as sess: sess.run(init) # 初始化所有变量 [^5] result = sess.run(some_tensor_or_operation) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值