Skip to main content
 首页 » 编程设计

python之Theano 无法使用 theano 配置 cnmem = 1 导入

2025年04月02日752php

Theano导入失败,theano配置cnmem = 1

知道如何确保 GPU 完全分配给 theano python 脚本吗?

Note: Display is not used to avoid its GPU usage

文件:.theanorc

cnmem = 1 

文件:test.py

print 'Importing Theano Library ...' 
import theano 
print 'Imported' 

输出:

$ python test.py  
Importing Theano Library ...  
Killed  
$ 

它只适用于 cnmem = 0.75

文件:.theanorc

cnmem = 0.75 

输出:

$ python test.py 
Importing Theano Library ... 
Imported 
$  

请您参考如下方法:

https://github.com/Theano/Theano/issues/4302#issuecomment-202067917

Could you try with 1.0 instead of 1? according to the docs, it needs to be a float. Also, it is limited to 0.95 to allow space for device drivers. So, you can't use the entire GPU memory just like you can't use all of RAM.