DOTY
ML Agents 준비 본문
머신러닝을 위한 가상환경 구축
1. Python + Miniconda
파이썬과 아나콘다를 사용해서 구축한다. (나는 미니콘다를 썼다)
Python Release Python 3.10.11 | Python.org
Python Release Python 3.10.11
The official home of the Python Programming Language
www.python.org
Miniconda — Anaconda documentation
Miniconda — Anaconda documentation
These three commands quickly and quietly download the latest 64-bit Windows installer, rename it to a shorter file name, silently install, and then delete the installer: curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -o minic
docs.anaconda.com
두개를 받은 다음에 cmd에서 확인할 수 있다.
python --version
conda --version
2. 사용할 폴더에 가상환경 만들기
conda create -n mlagent python=3.10.12
중간에 뭐 뜨다가 Y/N 뜨면 Y 입력해줄것. (-n 뒤에 가상환경 이름을 정해줄 수 있다. 나는 mlagent)
다 끝난 후에
conda activate mlagent
콘솔 맨 앞에 가상환경 이름이 뜨면 성공
3. Unity에서 사용하기 위해 설치할 것들
// pip 설치
python -m pip install --upgrade pip
// Unity에서 ML Agent를 활용하기 위해 Git에서 가져온다.
git clone --branch release_22 https://github.com/Unity-Technologies/ml-agents.git
GitHub - Unity-Technologies/ml-agents: The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enab
The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement ...
github.com
Git을 받고 나중에 Unity에서 예제를 확인해볼 수 있다.
아참, Unity에서도 MLAgent를 받아줘야한다.
Unity Registry에 있을 것이다. 그리고 귀여운 상자를 얻고 싶다면 3D Ball도 함께 받아준다. (아까 말한 예제가 3D Ball)
CMD창에서 ml-agents폴더로 꼭 들어간 후에 다음을 설치한다.
// 파이토치 설치
pip install torch==2.1.1 -f https://download.pytorch.org/whl/torch_stable.html
// ml Agents 설치
python -m pip install ./ml-agents-envs
python -m pip install ./ml-agents
// 잘 설치됐나 확인
mlagents-learn --help
// 실행
mlagents-learn
유니티에 들어가서 Play 버튼을 누르면 좋지 않은 결과가 있을 수 있다... (나는 멈췄다.)
Ctrl + C 로 나갈 수 있고, 실행할 때 만약 기존에 실행하던 것이 있다면 mlagents-learn 뒤에 옵션을 붙여준다.
mlagents-learn --force // 덮어쓰기
mlagents-learn --resume // 이어하기
준비 완료!
'Unity' 카테고리의 다른 글
ECS (Entity Component System) - Setup (1) | 2024.11.21 |
---|---|
Behavior Tree (0) | 2024.11.14 |
HpProgressBar 체력에 따라 색 바꾸기 (0) | 2024.10.14 |
[Unity] err1. object reference not set to an instance of an object (0) | 2022.09.24 |
[Unity] 6. Scene 변경 ( + DontDestroyOnLoad ) (0) | 2022.09.07 |