티스토리 뷰

728x90
반응형

jupyter notebook에서 잘 동작하는 간단한 딥러닝 모델을 jupyter lab 상에서 

학습(fit, fit_generator)코드를 실행시켰을 때 정상적으로 넘어가지 않고 

다음과 같은 에러 메시지가 나타났다. 

InvalidArgumentError: 
device CUDA:0 not supported by XLA service
      while setting up XLA_GPU_JIT device number 0

검색해보니 CUDA_VISIBLE_DEVICES관련해서 학습코드가 할당된 GPU를 선택해주는 명령을 shell상에서 지정해주거나 코드상에서 지정하면 된다고 해결책을  제시하고 있다. 

 

터미널 shell에서 다음과 같이 명령을 입력하면 된다.

$ export CUDA_VISIBLE_DEVICES=0,1,2,3

자신의 GPU숫자에 맞게 번호를 지정하면 된다. 

 

또는 코드에서 os 라이브러리를 이용하여 다음과 같이 지정할 수 있다고 한다.

import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2,3'

역시 마지막 0,1,2,3은 자신의 GPU숫자와 비어있는 GPU를 선택해서 지정하면 된다. 

 

참고한 자료의 링크는 다음과 같다.

https://github.com/keras-team/keras/issues/12393

 

Error selecting GPU programmatically from jupyter · Issue #12393 · keras-team/keras

I have a multi-GPU machine and am trying to train different models on different GPUs. I'm trying to set the GPU programmatically rather than use env vars, but am running into issues. Here's...

github.com

https://inneka.com/ml/tf/tensorflow-device-cuda0-not-supported-by-xla-service-while-setting-up-xla_gpu_jit-device-number-0/

 

Tensorflow: device CUDA:0 not supported by XLA service while setting up XLA_GPU_JIT device number 0 – inneka.com

This could be due to your TF-default (i.e. 1st) GPU is running out of memory. If you have multiple GPUs, divert your Python program to run on other GPUs. In TF (suppose using TF-2.0-rc1), set the following: # Specify which GPU(s) to use os.environ["CUDA_VI

inneka.com

 

728x90
반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함