728x90
반응형
로컬에서는 문제없이 돌아가는 코드가 AWS 서버로 옮기니까 다음과 같은 에러가 발생했다.
terminate called after throwing an instance of 'std::runtime_error'
what(): random_device could not be read
난생 처음보는 에러이고 로컬에서는 돌아가니 난감했다.
그래도 다행히 하나만 추가했는데 에러가 발생해서 금방 원인을 찾을 수 있었다.
내가 추가한건 ultralytics이고, import torch를 포함하는 라이브러리이다.
결론부터 말하자면 라이브러리 import 순서에 따른 AWS에서만 발생하는 에러였다.
torch와 tensorflow를 동시에 import를 하면 에러가 발생하는데,
torch를 먼저 import하고, tensorflow를 나중에 import하면 문제가 해결된다.
왜 이런게 발생하는지는 찾지 못했는데
한번 원인을 찾고 싶은분들은 pytorch issues를 찾아보면 좋겠다.
https://github.com/pytorch/pytorch/issues/101152
Importing torch after TensorFlow results in std::runtime_error · Issue #101152 · pytorch/pytorch
🐛 Describe the bug The following minimal example (Dockerfile, just run docker build with it ) reproduces the error: FROM python:3.11.3 RUN pip install tensorflow==2.12.0 torch==2.0.1 RUN python -c ...
github.com
import tensorflow
import torch
"""
terminate called after throwing an instance of 'std::runtime_error'
what(): random_device could not be read
Aborted (core dumped)
"""
import torch
import tensorflow
"""
no err
"""
728x90
반응형
'개발 > AWS' 카테고리의 다른 글
백그라운드로 파이썬 파일 실행 관리하기 (0) | 2023.12.21 |
---|---|
AWS 포트(방화벽) 연결 실수 해결 [ufw 문제] (2) | 2023.10.17 |
AWS EC2 디스크 용량 늘리기 (0) | 2023.07.07 |
AWS pymysql [ 2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))] 에러 해결 (0) | 2023.06.27 |
EC2 파이썬 서버 항상 실행되게 하기 (0) | 2023.06.27 |
댓글