본문 바로가기
AI/강화학습

2. [OPENAI] Installation(Window)

by 보안매크로 2025. 1. 17.
728x90

1. 아래 명령어로 WSL 필수 기능 활성화

powershell(관리자 권한) 실행 후 명령어 입력

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

 

2. WSL 최신 버전 설치

wsl --install

이 명령은 WSL을 최신 상태로 업데이트하고 기본 배포판(Ubuntu)을 설치합니다.

 

3.  WSL 2 설정

wsl --set-default-version 2

이후 PC 재부팅

 

4.  "가상 머신 플랫폼"을 사용하도록 설정

wsl.exe --install --no-distribution

PC 재부팅 한번 더 진행.

재부팅 이후 위 사진 처럼 명령어 입력 시, 잘 나오면 정상

 

5. Ubuntu 터미널 열기(윈도우 검색창에 검색하면 나옵니다)

 

6. 시스템 업데이트 및 업그레이드

sudo apt update && sudo apt full-upgrade -y

 

7. 필수 패키지 설치

sudo apt install x11-apps -y
sudo apt install octave -y

 

8. Miniconda 다운로드

https://chatgpt.com/g/g-p-678994cfc3388191a1ed77f51f8d0f31-openai-rl/c/678994f8-5fd8-8004-9038-f5c650cb1764

Linux용 Miniconda 설치 파일을 다운로드

 64-Bit (x86) Installer 를 설치합니다.

 

9. Miniconda 설치

Ubuntu 터미널에서 아래 절차를 진행

1. 설치 경로로 이동(/mnt/를 사용하면, window 디스크에 접근 가능)

cd /mnt/c/Users/<YourUsername>/Downloads

2. 파일 복사 파일을 Ubuntu 홈 디렉토리로 복사:

cp python-3.12.x-linux-x86_64.sh ~/

3. Ubuntu 홈 디렉토리에서 설치 Ubuntu 홈 디렉토리(~)로 이동한 후 파일 설치:

cd ~
bash python-3.12.x-linux-x86_64.sh

설치중, 엔터를 누르고, yes 입력해주면 된다.
설치가 완료되면 우분투 터미널 창을 껐다가 다시 켜준다.

 

10. Conda 환경 생성

1. Conda 환경 생성

conda create -n spinningup python=3.6 -y

2. 환경 활성화

conda activate spinningup

 

11. 필수 패키지 설치

1. MPI4Py 및 MPICH 설치
- 강화학습이나 병렬 처리를 수행할 때, 여러 프로세스를 효과적으로 관리하고 데이터를 주고받을 수 있도록 돕는 도구들

conda install -c conda-forge mpi4py mpich -y

2. OpenCV 특정 버전 설치

pip install opencv-python==3.4.13.47

3. OpenMPI 설치

sudo apt-get update
sudo apt-get install libopenmpi-dev -y

 

12. Spinning Up 설치

0. (추천 사항) 작업 전용 디렉토리 생성

mkdir ~/projects
cd ~/projects

1. Git 저장소 클론

git clone https://github.com/openai/spinningup.git

2. 디렉토리 이동

cd spinningup

3. 설치 실행

pip install -e .

 

13. 설치 확인

1. PPO 실행 테스트

python -m spinup.run ppo --hid "[32,32]" --env LunarLander-v2 --exp_name installtest --gamma 0.999

10분정도 소요됩니다. 

2. 학습 정책 시각화 (결과 시각화)

python -m spinup.run test_policy data/installtest/installtest_s0

3. 결과 확인

python -m spinup.run plot data/installtest/installtest_s0

13-2 절차에서 subprocess.CalledProcessError: Command '['/root/anaconda3/envs/spinningup/bin/python', '/root/OpenAIRL/spinningup/spinup/utils/test_policy.py', 'data/installtest/installtest_s0']' died with <Signals.SIGSEGV: 11>.
에러 발생 시, LIBGL_ALWAYS_SOFTWARE 환경 변수 설정을 해준다.

export LIBGL_ALWAYS_SOFTWARE=1

 

728x90

'AI > 강화학습' 카테고리의 다른 글

4. [OPENAI] Running Experiments  (0) 2025.01.21
3. [OPENAI] Algorithms  (0) 2025.01.20
1. [OpenAI] Spinning Up in Deep RL Introduction  (1) 2025.01.16
Model Free Control  (0) 2024.06.25
Model Free Prediction  (0) 2024.06.16