V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
KarlRixon
V2EX  ›  TensorFlow

安装 tensorflow 的 gpu 版后 import 报错,有大佬碰到过这种情况吗?

  •  
  •   KarlRixon · 2019-02-14 11:45:48 +08:00 · 8103 次点击
    这是一个创建于 1888 天前的主题,其中的信息可能已经有所发展或是发生改变。

    首先 cuda 装的是 9.1.85_win10_64 位,是在百度网盘上下载的 local 可执行文件(因为官网的下载太慢而且联网版安装包也很慢),用 vs2015 测试自带 Samples 成功。
    然后 cudnn 是下载官网的 9.0 版本,但是按照网上做法测试报错:

    #include <iostream>
    #include <cuda_runtime.h>
    #include <cudnn.h>
    using namespace std;
    
    void main() {
    	cudnnHandle_t handle;
    	cudnnStatus_t t = cudnnCreate(&handle);
    	cout << cudnnGetErrorString(t);
    	getchar();
    }
    

    错误 MSB3721 命令“"D:\CUDA9.2\Development\bin\nvcc.exe" -gencode=arch=compute_30,code="sm_30,compute_30" --use-local-env --cl-version 2015 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin" -x cu -ID:\CUDA9.2\Development\include -ID:\CUDA9.2\Development\include -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MDd " -o Debug\test.cu.obj "C:\Users\24346\Documents\C++\testCUDA\test_cudnn\test_cudnn\test.cu"”已退出,返回代码为 1。

    Microsoft Visual C++ 2017 Redistributable(X64)已安装
    python 是 3.6.8 版本的 64 位,pip install tensorflow-gpu 显示安装成功,但 import tensorflow 报错:

    ImportError: Traceback (most recent call last):
      File "D:\anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
        return importlib.import_module(mname)
      File "D:\anaconda\envs\tensorflow-gpu\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 978, in _gcd_import
      File "<frozen importlib._bootstrap>", line 961, in _find_and_load
      File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 560, in module_from_spec
      File "<frozen importlib._bootstrap_external>", line 922, in create_module
      File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
    ImportError: DLL load failed: 找不到指定的模块。
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "D:\anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "D:\anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "D:\anaconda\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
        return importlib.import_module('_pywrap_tensorflow_internal')
      File "D:\anaconda\envs\tensorflow-gpu\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
    
    
    Failed to load the native TensorFlow runtime.
    
    See https://www.tensorflow.org/install/install_sources#common_installation_problems
    
    for some common reasons and solutions.  Include the entire stack trace
    above this error message when asking for help.
    

    使用 anaconda 安装 tensorflow-gpu 也出现这个 ImportError
    现在我安装了 tensorflow 的 cpu 版就没有这个问题了。。。
    想问一下 10000 条以内评论的词向量训练需要显卡加速吗

    5 条回复    2019-02-21 19:01:46 +08:00
    julyclyde
        1
    julyclyde  
       2019-02-14 12:53:43 +08:00
    Failed to load the native TensorFlow runtime
    kisara
        2
    kisara  
       2019-02-14 17:29:03 +08:00
    为啥在 windows 上装 tf 这不是跟自己过不去嘛。。
    KarlRixon
        3
    KarlRixon  
    OP
       2019-02-16 21:01:47 +08:00
    cudnn 测试需要在链接器输入中添加 cudart.lib
    tinywhale
        4
    tinywhale  
       2019-02-21 07:22:43 +08:00
    是 cuda 版本不对,版本号要和编译时用的一样
    KarlRixon
        5
    KarlRixon  
    OP
       2019-02-21 19:01:46 +08:00
    @tinywhale 已经安装好了,现在用的是 cuda10.0,tensorflow 用的一个大佬的轮子
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3475 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 11:51 · PVG 19:51 · LAX 04:51 · JFK 07:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.