OOTDiffusion icon indicating copy to clipboard operation
OOTDiffusion copied to clipboard

How do I set device in CUda?

Open TanvirHafiz opened this issue 1 year ago • 6 comments

This is the error i get when trying to run in gradio!

(venv) F:\OOTDiffusion\run>python gradio_ootd.py Traceback (most recent call last): File "F:\OOTDiffusion\run\gradio_ootd.py", line 20, in openpose_model_hd = OpenPose(0) File "F:\OOTDiffusion\preprocess\openpose\run_openpose.py", line 32, in init torch.cuda.set_device(gpu_id) File "F:\venv\lib\site-packages\torch\cuda_init_.py", line 350, in set_device torch._C._cuda_setDevice(device) AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'

TanvirHafiz avatar Apr 03 '24 05:04 TanvirHafiz

Maybe it depends on whether your computer graphics card supports CUDA

caishen0311 avatar Apr 06 '24 02:04 caishen0311

My GPU is RTX 3060Ti and I also get above same error when run in run_ootd.py. How can i solve it? @TanvirHafiz did you sovled it?

shinjeongmin avatar Apr 15 '24 14:04 shinjeongmin

Maybe it depends on whether your computer graphics card supports CUDA

of course my GPU has CUDA. its am nvidia 3060. anyway, upgraded to a 3090. i can try again

TanvirHafiz avatar Apr 15 '24 15:04 TanvirHafiz

does not tun in 3090.there is a definite error in the coding that is stopping it!

TanvirHafiz avatar Apr 15 '24 15:04 TanvirHafiz

I had the same issue. I resolved it installing cuda on my windows machine: https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=11&target_type=exe_local

Then installing the necessary packages in the conda env: https://pytorch.org/get-started/locally/ conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

FilipBoe avatar May 04 '24 14:05 FilipBoe

I only one 3090 gpu card, also have a issue, (1) update "cuda_init_.py" code in 350: torch._C._cuda_setDevice(device) to torch._C._cuda_setDevice(0)

(2) update "torch\nn\modules\module.py" in 1144: return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) TO return t.to(0, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)

(3) update "transformers\tokenization_utils_base.py" in 790: self.data = {k: v.to(device=device) for k, v in self.data.items()} TO self.data = {k: v.to(device=0) for k, v in self.data.items()}

(4) update "inference_ootd_dc.py" in 35: self.gpu_id = 'cuda:' + str(gpu_id) TO self.gpu_id = 'cuda:' + str(0)

problem have solve !!

algorithm000 avatar Jun 16 '24 16:06 algorithm000