当前位置:   article > 正文

windows下安装tensorflow(GPU/CPU)_windows安装tensorflow

windows安装tensorflow

ERROR: You appear to be running an X server; please exit X before            
         installing.  For further details, please see the section INSTALLING   
         THE NVIDIA DRIVER in the README available on the Linux driver         
         download page at www.nvidia.com.

sudo ./NVIDIA-Linux-x86_64-535.86.05.run -no-opengl-files -no-x-check

ERROR: An NVIDIA kernel module 'nvidia' appears to already be loaded in your
         kernel.  This may be because it is in use (for example, by an X       
         server, a CUDA program, or the NVIDIA Persistence Daemon), but this   
         may also happen if your kernel was configured without support for     
         module unloading.  Please be sure to exit any programs that may be    
         using the GPU(s) before attempting to upgrade your driver.  If no     
         GPU-based programs are running, you know that your kernel supports    
         module unloading, and you still receive this message, then an error   
         may have occurred that has corrupted an NVIDIA kernel module's usage  
         count, for which the simplest remedy is to reboot your computer.

sudo apt-get remove --purge nvidia*

一、安装tensorflow_gpu

官方安装网址 TensorFlow (google.cn)

(1)安装anaconda3

(2)打开 Anaconda Prompt

(3)创建环境

        【注意】这里只是配置好环境,并未安装tensorflow

          conda create -n tensorflow_gpu python=3.9

        (python版本参考使用 pip 安装 TensorFlow (google.cn)

       

       在 Windows 环境中从源代码构建  |  TensorFlow (google.cn)         

cudnn下载:cuDNN Archive | NVIDIA Developer

cuda下载:CUDA Toolkit Archive | NVIDIA Developer

安装cuda,解压cudnn-11.2-windows-x64-v8.1.0.77,文件夹重命名为cudnn,放入cuda的安装文件夹里。

编辑环境变量cuda和cudnn:

      

        出现:

        

 在anaconda安装目录下envs文件夹下可以看到:

         

(4)激活

        conda activate tensorflow_gpu

  (5) 安装 tensorflow-gpu

        在线安装:

                                pip install tensorflow-gpu==2.6.0

                                或

                                pip install --ignore-installed --upgrade tensorflow_gpu==2.6.0

       离线安装:

               下载tensorflow-gpu安装包: tensorflow-gpu · PyPI

               pip install C\tensorflow_gpu-2.6.0-cp39-cp39-win_amd64.whl

                离线安装时,会联网下载第三方库,出现超时错误时,忽略。不停重复安装即可

 完成后:

  

运行tensorflow程序,在cmd里运行nvidia-smi 查看gpu使用情况。

二、安装tensorflow

conda create - -name tensorflow python=3.10

                     

    

三、问题

(1)ImportError: cannot import name 'dtensor' from 'tensorflow.compat.v2.experimental'

原因:keras与tensorflow版本不匹配,将keras 2.9.0 降至2.6.0

 在tensorflow-gpu环境下执行:pip install keras==2.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号