问答交流

LSTM/CNN层运行提示Physical devices cannot be modified after being initialized

由howie1013创建,最终由howie1013 被浏览 19 用户

问题

<ERROR: moduleinvoker: module name: dl_layer_lstm, module version: v1, trackeback: RuntimeError: Physical devices cannot be modified after being initialized>

请问是什么原因?配置了一块GPU,重启了开发环境也不行,一直提示这个错误

https://bigquant.com/experimentshare/ad9ddc0550d64dfa933ceaaf28f61e21

解答

您好,麻烦您这边重启下内核。然后运行下面的程序的第一个cell看看可不可以成功。可以成功在运行画布。


https://bigquant.com/experimentshare/5fd9db8403ba4113bee1416bda0dab19

或者如下运行代码

import tensorflow as tf 
gpus = tf.config.list_physical_devices('GPU') 
if gpus: 
try: 
# Currently, memory growth needs to be the same across GPUs 
for gpu in gpus: 
tf.config.experimental.set_memory_growth(gpu, True) 
logical_gpus = tf.config.list_logical_devices('GPU') 
print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs") 
except RuntimeError as e: 
# Memory growth must be set before GPUs have been initialized 
print(e)

\

标签

LSTMCNN
评论
  • 您好,麻烦您这边重启下内核。然后运行下面的程序的第一个cell看看可不可以成功。可以成功在运行画布。 [https://bigquant.com/experimentshare/5fd9db8403ba4113bee1416bda0dab19](https://bigquant.com/experimentshare/5fd9db8403ba4113bee1416bda0dab19) \
  • import tensorflow as tf gpus = tf.config.list_physical_devices('GPU') if gpus: try: \# Currently, memory growth needs to be the same across GPUs for gpu in gpus: tf.config.experimental.set_memory_growth(gpu, True) logical_gpus = tf.config.list_logical_devices('GPU') print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs") except RuntimeError as e: \# Memory growth must be set before GPUs have been initialized print(e) \ 或者运行如上代码
{link}