python 请帮助安装Tensorflow和CUDA驱动程序

tv6aics1  于 2023-04-10  发布在  Python
关注(0)|答案(2)|浏览(95)

我有CUDA驱动程序和TensorFlow的干净安装,但我无法让TensorFlow使用我的CUDA驱动程序。
我的Windows 11 Pro版本是22 H2。
我正在运行Anaconda Python 3.9.15。
以下是我的CUDA驱动程序的信息(通过运行nvidia-smi):

Sat Apr  8 16:44:56 2023
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 531.14                 Driver Version: 531.14       CUDA Version: 12.1     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                      TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf            Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 2080 S...  WDDM | 00000000:01:00.0  On |                  N/A |
| N/A   48C    P8               10W /  N/A|   2049MiB /  8192MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

我安装的TensorFlow显示:

>pip install tensorflow
Requirement already satisfied: tensorflow in h:\anaconda3\lib\site-packages (2.10.0)
Requirement already satisfied: wrapt>=1.11.0 in h:\anaconda3\lib\site-packages (from tensorflow) (1.15.0)
Requirement already satisfied: keras<2.11,>=2.10.0 in h:\anaconda3\lib\site-packages (from tensorflow) (2.10.0)
Requirement already satisfied: flatbuffers>=2.0 in h:\anaconda3\lib\site-packages (from tensorflow) (23.1.21)
Requirement already satisfied: typing-extensions>=3.6.6 in h:\anaconda3\lib\site-packages (from tensorflow) (4.5.0)
Requirement already satisfied: packaging in h:\anaconda3\lib\site-packages (from tensorflow) (23.0)
Requirement already satisfied: absl-py>=1.0.0 in h:\anaconda3\lib\site-packages (from tensorflow) (1.4.0)
Requirement already satisfied: opt-einsum>=2.3.2 in h:\anaconda3\lib\site-packages (from tensorflow) (3.3.0)
Requirement already satisfied: numpy>=1.20 in h:\anaconda3\lib\site-packages (from tensorflow) (1.21.6)
Requirement already satisfied: six>=1.12.0 in h:\anaconda3\lib\site-packages (from tensorflow) (1.16.0)
Requirement already satisfied: libclang>=13.0.0 in h:\anaconda3\lib\site-packages (from tensorflow) (14.0.6)
Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in h:\anaconda3\lib\site-packages (from tensorflow) (0.27.0)
Requirement already satisfied: keras-preprocessing>=1.1.1 in h:\anaconda3\lib\site-packages (from tensorflow) (1.1.2)
Requirement already satisfied: tensorflow-estimator<2.11,>=2.10.0 in h:\anaconda3\lib\site-packages (from tensorflow) (2.10.0)
Requirement already satisfied: grpcio<2.0,>=1.24.3 in h:\anaconda3\lib\site-packages (from tensorflow) (1.46.0)
Requirement already satisfied: setuptools in h:\anaconda3\lib\site-packages (from tensorflow) (65.6.3)
Requirement already satisfied: astunparse>=1.6.0 in h:\anaconda3\lib\site-packages (from tensorflow) (1.6.3)
Requirement already satisfied: termcolor>=1.1.0 in h:\anaconda3\lib\site-packages (from tensorflow) (2.2.0)
Requirement already satisfied: tensorboard<2.11,>=2.10 in h:\anaconda3\lib\site-packages (from tensorflow) (2.10.1)
Requirement already satisfied: protobuf<3.20,>=3.9.2 in h:\anaconda3\lib\site-packages (from tensorflow) (3.19.6)
Requirement already satisfied: gast<=0.4.0,>=0.2.1 in h:\anaconda3\lib\site-packages (from tensorflow) (0.4.0)
Requirement already satisfied: h5py>=2.9.0 in h:\anaconda3\lib\site-packages (from tensorflow) (2.10.0)
Requirement already satisfied: google-pasta>=0.1.1 in h:\anaconda3\lib\site-packages (from tensorflow) (0.2.0)
Requirement already satisfied: wheel<1.0,>=0.23.0 in h:\anaconda3\lib\site-packages (from astunparse>=1.6.0->tensorflow) (0.40.0)
Requirement already satisfied: google-auth<3,>=1.6.3 in h:\anaconda3\lib\site-packages (from tensorboard<2.11,>=2.10->tensorflow) (2.17.2)
Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in h:\anaconda3\lib\site-packages (from tensorboard<2.11,>=2.10->tensorflow) (0.6.1)
Requirement already satisfied: werkzeug>=1.0.1 in h:\anaconda3\lib\site-packages (from tensorboard<2.11,>=2.10->tensorflow) (2.2.3)
Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in h:\anaconda3\lib\site-packages (from tensorboard<2.11,>=2.10->tensorflow) (0.4.6)
Requirement already satisfied: requests<3,>=2.21.0 in h:\anaconda3\lib\site-packages (from tensorboard<2.11,>=2.10->tensorflow) (2.28.2)
Requirement already satisfied: markdown>=2.6.8 in h:\anaconda3\lib\site-packages (from tensorboard<2.11,>=2.10->tensorflow) (3.4.3)
Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in h:\anaconda3\lib\site-packages (from tensorboard<2.11,>=2.10->tensorflow) (1.8.1)
Requirement already satisfied: rsa<5,>=3.1.4 in h:\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard<2.11,>=2.10->tensorflow) (4.9)
Requirement already satisfied: pyasn1-modules>=0.2.1 in h:\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard<2.11,>=2.10->tensorflow) (0.2.7)
Requirement already satisfied: cachetools<6.0,>=2.0.0 in h:\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard<2.11,>=2.10->tensorflow) (5.3.0)
Requirement already satisfied: requests-oauthlib>=0.7.0 in h:\anaconda3\lib\site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.11,>=2.10->tensorflow) (1.3.1)
Requirement already satisfied: importlib-metadata>=4.4 in h:\anaconda3\lib\site-packages (from markdown>=2.6.8->tensorboard<2.11,>=2.10->tensorflow) (6.2.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in h:\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.11,>=2.10->tensorflow) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in h:\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.11,>=2.10->tensorflow) (2022.12.7)
Requirement already satisfied: idna<4,>=2.5 in h:\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.11,>=2.10->tensorflow) (3.4)
Requirement already satisfied: charset-normalizer<4,>=2 in h:\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.11,>=2.10->tensorflow) (2.1.1)
Requirement already satisfied: MarkupSafe>=2.1.1 in h:\anaconda3\lib\site-packages (from werkzeug>=1.0.1->tensorboard<2.11,>=2.10->tensorflow) (2.1.2)
Requirement already satisfied: zipp>=0.5 in h:\anaconda3\lib\site-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard<2.11,>=2.10->tensorflow) (3.15.0)
Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in h:\anaconda3\lib\site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard<2.11,>=2.10->tensorflow) (0.4.8)
Requirement already satisfied: oauthlib>=3.0.0 in h:\anaconda3\lib\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.11,>=2.10->tensorflow) (3.2.2)

当我运行以下测试时,它显示TensorFlow无法找到CUDA驱动程序

>python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
[]
qltillow

qltillow1#

1.检查您的CUDA安装是否存在任何问题:

  • nvcc -V*

1.验证是否已正确设置环境变量:CUDA_HOME:CUDA安装目录的路径。PATH:CUDA和cuDNN bin目录的路径。LD_LIBRARY_PATH:CUDA和cuDNN库目录的路径。
1.如果TensorFlow正在检测您的GPU:
将tensorflow导入为tf print(tf.config.list_physical_devices('GPU'))

ppcbkaq5

ppcbkaq52#

ysun wrote:安装tensorflow-gpu。
当我这样做时,我得到:

C:\>pip install tensorflow-gpu
Collecting tensorflow-gpu
  Downloading tensorflow-gpu-2.12.0.tar.gz (2.6 kB)
  Preparing metadata (setup.py) ... done
Collecting python_version>"3.7"
  Downloading python_version-0.0.2-py2.py3-none-any.whl (3.4 kB)
Building wheels for collected packages: tensorflow-gpu
  Building wheel for tensorflow-gpu (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\cbrau\AppData\Local\Temp\pip-install-elvw6znm\tensorflow-gpu_6e567a8802be4168b4acf33b7f23d8ca\setup.py", line 37, in <module>
          raise Exception(TF_REMOVAL_WARNING)
      Exception:

      =========================================================
      The "tensorflow-gpu" package has been removed!

      Please install "tensorflow" instead.

      Other than the name, the two packages have been identical
      since TensorFlow 2.1, or roughly since Sep 2019. For more
      information, see: pypi.org/project/tensorflow-gpu
      =========================================================

相关问题