본문 바로가기

Python4

[Pytorch / Tensorflow] GPU 확인, 특정 GPU 사용 방법 사용가능한 GPU 살펴보는 법 (ubuntu terminal / anaconda terminal 등) $ nvidia-smi "CUDA_VISIBLE_DEVICES"를 통해 cuda가 볼 수 있는 GPU 제한하기 import os os.environ["CUDA_VISIBLE_DEVICES"] = "3" 별도의 설정을 하지 않으면 cuda는 GPU 0번을 사용하려 한다. GPU:n번 을 사용하려면 번호를 n으로 지정해주면 된다. 위의 예시에서는 GPU:3 이 사용된다. CPU 강제사용을 원하는 경우 -1로 번호를 선택해주면 된다. Pytorch import torch print(torch.cuda.is_available()) # False = cpu # True = gpu 사용가능 사용 예시 : devic.. 2023. 5. 8.
libssl.so.10: cannot open shared object file: No such file or directory huggingface의 transformers를 설치후에 from transformers import AutoTokenizer 를 사용하였더니 다음과 같은 오류가 발생하였다. RuntimeError: Failed to import transformers.models.auto.tokenization_auto because of the following error (look up to see its traceback): libssl.so.10: cannot open shared object file: No such file or directory 허깅페이스 공식사이트에서 conda를 사용하여 transformers를 설치할 때 다음과 같이 conda install -c huggingface transform.. 2023. 5. 4.
[Python] AttributeError: 'NoneType' object has no attribute 'copy' opencv를 사용하던 중 AttributeError: 'NoneType' object has no attribute 'copy' 라는 오류가 발생했다. 원인은 경로에 한글명이 들어가있던 것. 영어로 경로들을 바꿔주니 정상작동하였다. 2023. 1. 19.
[Python] 헷갈렸던 문법(코딩테스트 / 프로젝트) [문자열, str] replace 함수 my_string = "ABCB" my_string.replace('B', '') -------------------------- 'AC' [ List ] index 함수 리스트에서 해당 원소의 위치가 어딘지 알려주는 함수 a = [11,10,12,13,20,31,11,10,10,11] print(a.index(10)) ----------------------------------- 1 Join 함수 리스트를 문자열로 ''.join(list_name) del 함수 삭제하고 싶은 값을 인덱스로 지정합니다. l = list(range(10)) print(l) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] del l[0] print(l) # [1, 2, 3,.. 2023. 1. 17.