首页 > 解决方案 > 停止 TensorFlow 尝试临时加载 cuda

问题描述

我有这个代码来禁用 GPU 使用:

import numpy as np

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"

import tensorflow as tf
w = tf.Variable(
    [
        [1.],
        [2.]
    ])

我仍然得到这个输出,不知道为什么:

E:\MyTFProject\venv\Scripts\python.exe E:/MyTFProject/tfvariable.py
2021-11-03 14:09:16.971644: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-11-03 14:09:16.971644: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2021-11-03 14:09:19.563793: E tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2021-11-03 14:09:19.566793: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: newtonpc
2021-11-03 14:09:19.567793: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: mypc
2021-11-03 14:09:19.567793: 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:  AVX
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

TF 版本:'2.6.1' 无法阻止它加载 Cuda DLL。我现在不想设置 cuda。也许以后。

我正在使用最新的 PyCharm 并安装了站点中给出的 tensorflow 和 pip。

标签: tensorflow

解决方案


您可以尝试使用纯 CPU 版本重新安装 tensorflow。此处提供的链接取决于您的操作系统和 python 版本: https ://www.tensorflow.org/install/pip?hl=fr#windows_1


推荐阅读