Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUDA_ERROR_OUT_OF_MEMORY #39

Closed
resuly opened this issue Aug 29, 2017 · 3 comments
Closed

CUDA_ERROR_OUT_OF_MEMORY #39

resuly opened this issue Aug 29, 2017 · 3 comments

Comments

@resuly
Copy link

resuly commented Aug 29, 2017

It works fine with THEANO_FLAGS_GPU:

set THEANO_FLAGS=%THEANO_FLAGS_GPU%
C:\Users\resuly\Desktop>python cpu_gpu_test.py
Can not use cuDNN on context None: Disabled by dnn.enabled flag
Preallocating 1638/2048 Mb (0.800000) on cuda0
Mapped name None to device cuda0: GeForce GTX 960M (0000:01:00.0)
[GpuElemwise{exp,no_inplace}(<GpuArrayType<None>(float32, (False,))>), HostFromGpu(gpuarray)(GpuElemwise{exp,no_inplace}.0)]
Looping 1000 times took 0.274695 seconds
Result is [ 1.23178029  1.61879349  1.52278066 ...,  2.20771813  2.29967761
  1.62323296]
Used the gpu

However, it showed me a memory error when I used GPU with CUDA. ( pygpu is 0.6.9 version )

set THEANO_FLAGS=%THEANO_FLAGS_GPU_DNN%
C:\Users\resuly\Desktop>python cpu_gpu_test.py
Using cuDNN version 5110 on context None
WARNING: Preallocating too much memory can prevent cudnn and cublas from working properly
ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
Traceback (most recent call last):
  File "D:\Anaconda3\lib\site-packages\theano\gpuarray\__init__.py", line 164, in <module>
    use(config.device)
  File "D:\Anaconda3\lib\site-packages\theano\gpuarray\__init__.py", line 151, in use
    init_dev(device)
  File "D:\Anaconda3\lib\site-packages\theano\gpuarray\__init__.py", line 90, in init_dev
    pygpu.empty((gmem,), dtype='int8', context=context)
  File "pygpu\gpuarray.pyx", line 749, in pygpu.gpuarray.empty
  File "pygpu\gpuarray.pyx", line 676, in pygpu.gpuarray.pygpu_empty
  File "pygpu\gpuarray.pyx", line 290, in pygpu.gpuarray.array_empty
pygpu.gpuarray.GpuArrayException: b'cuMemAlloc: CUDA_ERROR_OUT_OF_MEMORY: out of memory'
[Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)]

I don't think this is a real memory problem because THEANO_FLAGS_GPU works fine with the same script.
My environment variables:

THEANO_FLAGS_CPU
floatX=float32,device=cpu

THEANO_FLAGS_GPU
floatX=float32,device=cuda0,dnn.enabled=False,gpuarray.preallocate=0.8

THEANO_FLAGS_GPU_DNN
floatX=float32,device=cuda0,optimizer_including=cudnn,gpuarray.preallocate=0.8,dnn.conv.algo_bwd_filter=deterministic,dnn.conv.algo_bwd_data=deterministic,dnn.include_path=c:/CUDA/v8.0/include,dnn.library_path=c:/CUDA/v8.0/lib/x64

When I changed the pygpu back to 0.6.2 version. It shows:

C:\Users\resuly\Desktop>python cpu_gpu_test.py
ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
Traceback (most recent call last):
  File "D:\Anaconda3\lib\site-packages\theano\gpuarray\__init__.py", line 164, in <module>
    use(config.device)
  File "D:\Anaconda3\lib\site-packages\theano\gpuarray\__init__.py", line 151, in use
    init_dev(device)
  File "D:\Anaconda3\lib\site-packages\theano\gpuarray\__init__.py", line 60, in init_dev
    sched=config.gpuarray.sched)
  File "pygpu\gpuarray.pyx", line 614, in pygpu.gpuarray.init (pygpu/gpuarray.c:9415)
  File "pygpu\gpuarray.pyx", line 566, in pygpu.gpuarray.pygpu_init (pygpu/gpuarray.c:9106)
  File "pygpu\gpuarray.pyx", line 1021, in pygpu.gpuarray.GpuContext.__cinit__ (pygpu/gpuarray.c:13468)
pygpu.gpuarray.GpuArrayException: Error loading library: 0
[Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)]

BTW, tensorflow-gpu works well with CUDA. I don't know how to solve this problem.

@apacha
Copy link
Collaborator

apacha commented Aug 29, 2017

Do you specifically need the Theano backend? If not, I would recommend to just switch to the tensorflow backend in the meantime, as it seems to work better and in my experience faster as well.
As for the Theano flags, have you tried different values for the prealloc-flag? E.g. 0.7 or 0.6?

@resuly
Copy link
Author

resuly commented Aug 30, 2017

I'm learning the courses from fast.ai, which only support for Theano backend.
Anyway, thanks for your response. I am using the THEANO_FLAGS_GPU now.

@apacha
Copy link
Collaborator

apacha commented Dec 11, 2017

Since Theano development is officially discontinued, I'm not sure, if this issue is still relevant and you found a work-around, I am closing it.

@apacha apacha closed this as completed Dec 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants