4AI/TDEER

cannot use the GPU

Closed this issue · 4 comments

Excuse me, thanks for your great codes for joint model!!
when I use the code with tf=2.0 and keras=2.3.1, I canot use the GPU in my machine.
Could you please offer some adivces~
"
import os
os.system("CUDA_VISIBLE_DEVICES=1 python run.py --do_train --model_name NYT --rel_path data/NYT/rel2id.json --train_path data/NYT/train_triples.json "
"--dev_path data/NYT/test_triples.json --bert_dir pretrained-bert/cased_L-12_H-768_A-12 --save_path ckpts/nyt.model "
"--learning_rate 0.00005 --neg_samples 2 --epoch 200 --verbose 2 ")
"
thanks

Hi @tyistyler, thanks for following our project. We haven't tried to run the code in tensorflow>=2.0. We recommend running the code in tensorflow-gpu>1.14,tensorflow-gpu<2.0 .

Our dependencies about tensorflow are as follows:

$conda list | grep "tensorflow"
tensorflow                1.15.0          gpu_py37h0f0df58_0
tensorflow-base           1.15.0          gpu_py37h9dcbed7_0
tensorflow-estimator      1.15.1             pyh2649769_0
tensorflow-gpu            1.15.0               h0d30ee6_0

Oh, I see that you run the code via python os.system. You could try to add a new line os.environ['CUDA_VISIBLE_DEVICES']= '1' before os.system, i.e, you can refactor the code as follows:

import os

os.environ['CUDA_VISIBLE_DEVICES']= '1'

os.system("python run.py --do_train --model_name NYT --rel_path data/NYT/rel2id.json --train_path data/NYT/train_triples.json "
"--dev_path data/NYT/test_triples.json --bert_dir pretrained-bert/cased_L-12_H-768_A-12 --save_path ckpts/nyt.model "
"--learning_rate 0.00005 --neg_samples 2 --epoch 200 --verbose 2 ")

Oh, I see that you run the code via python os.system. You could try to add a new line os.environ['CUDA_VISIBLE_DEVICES']= '1' before os.system, i.e, you can refactor the code as follows:

import os

os.environ['CUDA_VISIBLE_DEVICES']= '1'

os.system("python run.py --do_train --model_name NYT --rel_path data/NYT/rel2id.json --train_path data/NYT/train_triples.json "
"--dev_path data/NYT/test_triples.json --bert_dir pretrained-bert/cased_L-12_H-768_A-12 --save_path ckpts/nyt.model "
"--learning_rate 0.00005 --neg_samples 2 --epoch 200 --verbose 2 ")

@tyistyler
Because we didn't test the code in TensorFlow2.x, we can not promise the code can successfully run in TensorFlow2.x. Look forward to your results in TF2.x!

Thanks for your reply, I solve it successfully (the reason is that there has some error of tensorflow's install). I use "conda install tensorflow==1.15.0" solve it.
Thanks!!!