加载模型权重

时间:2018-04-21 20:54:45

标签: tensorflow cudnn magenta

我正在尝试加载NSynth权重,我使用的是版本1.7.0

from magenta.models.nsynth import utils
from magenta.models.nsynth.wavenet import fastgen

def wavenet_encode(file_path):

 # Load the model weights.
 checkpoint_path = './wavenet-ckpt/model.ckpt-200000'

 # Load and downsample the audio.
 neural_sample_rate = 16000
 audio = utils.load_audio(file_path, 
                          sample_length=400000, 
                          sr=neural_sample_rate)

 encoding = fastgen.encode(audio, checkpoint_path, len(audio))

 # Reshape to a single sound.
 return encoding.reshape((-1, 16))

# An array of n * 16 frames. 
wavenet_z_data = wavenet_encode(file_path)

我收到以下错误:

  

tensorflow / stream_executor / cuda / cuda_dnn.cc:396]加载的运行时CuDNN   library:7103(兼容版本7100)但源代码已编译完成   7005(兼容版本7000)。如果使用二进制安装,   升级您的CuDNN库以匹配。如果从源头构建,请制作   确保在运行时加载的库与兼容版本匹配   在编译配置期间指定。

我应该怎么做,我应该安装哪个版本的tf,以及我需要哪个CUDA版本?

5 个答案:

答案 0 :(得分:8)

如错误所示,您使用的Tensorflow版本是针对CuDNN 7.0.5编译的,而您的系统安装了CuDNN 7.1.3。

如错误所示,您可以解决此问题:

答案 1 :(得分:6)

在环境:

ubuntu16.04   
cuda9.0   
cudnn7.0  
tensorflow 1.11.0  
python 3.5

我尝试用张量流训练对象检测,我遇到了这个问题:

2018-10-18 21:31:36.796017: E tensorflow/stream_executor/cuda/cuda_dnn.cc:343] Loaded runtime CuDNN library: 7.0.5 but source was compiled with: 7.2.1.  CuDNN library major and minor version needs to match or have higher minor version in case of CuDNN 7.0 or later version. If using a binary install, upgrade your CuDNN library.  If building from sources, make sure the library loaded at runtime is compatible with the version specified during compile configuration.
Segmentation fault (core dumped)

这是因为tensorflow版本更高;

我使用pip3 install --upgrade --force-reinstall tensorflow-gpu==1.9.0 --user来解决此问题。

答案 2 :(得分:1)

benjaminplanche's answer清楚地回答了这个问题。我想补充一点,希望对您有所帮助。

对于安装cuDNN,cudnnenv非常方便。

Cudnnenv 就像一个可以管理cuDNN各种版本的管理器。 使用pip可以轻松安装cudnnenv:

pip install cudnnenv

答案 3 :(得分:0)

我建议安装cudnn编译的tensorflow版本:

sudo apt install libcudnn7-dev=7.0.5.15-1+cuda<x> libcudnn7=7.0.5.15-1+cuda<x>

<x>符号必须替换为您拥有的cuda版本,例如对于cuda版本9.0,请将其替换为9.0

稍后冻结apt中不会自动更新的版本:

sudo apt-mark hold libcudnn7 libcudnn7-dev

答案 4 :(得分:0)

每晚安装Tensorflow可以为我解决问题:

pip3 install tf-nightly-gpu