본문 바로가기
소프트웨어 & 클라우드

[Windows] WSL2 .wslconfig 수정하여 사용 메모리 수정하기

by TaeGyeong Lee 2025. 1. 1.

개요 

WSL2 를 사용할 때, 호스트의 메모리를 최대한 많이 사용해야 할 때가 있습니다. (모델 학습 등.. ) .wslconfig 파일을 수정, 업데이트하여 wsl2가 사용 가능한 메모리의 양을 수정해보겠습니다. 참고로, wsl2 기본 메모리 제한 값은 호스트의 메모리 50%입니다. (16GB 메모리를 호스트가 가진다면, wsl2은 8GB 메모리 사용 제한)

전역 세팅을 담당하는 .wslconfig 파일과 다르게 wls.conf 파일을 수정하여 wsl2 배포별 구성을 따로 설정할 수 있습니다. 참고하세요. 

 

.wslconfig 파일 생성

wsl2에서는 .wslconfig 파일이 (생성하지 않았다면) 존재하지 않습니다. PowerShell 을 열어 아래 명령어를 입력하세요. 

cd ~
explorer .

 

위 명령이 정상적으로 입력되면, 파일탐색기가 나타납니다. 호스트의 %UserProfile% 디렉토리를 파일탐색기로 열었는데요. .wslconfig 파일을 생성하여 아래와 같이 내용을 작성, 저장하세요. 더 많은 옵션은 여기를 참고하세요. 

[wsl2]
memory=16GB

 

이제 아래 명령을 통해 PowerShell에서 wsl2을 종료하세요. 이후 wsl2을 다시 실행하면, 위에서 설정한 .wslconfig 파일 세팅이 wsl2에 적용됩니다. 

wsl --shutdown

 

.wslconfig 적용 확인하기

wsl2에서 아래 명령어를 통해 확인하세요. 

free -mh

 

참고 자료 

주의 
한글 번역판 문서를 읽지 마세요. 오역이 꽤 있습니다. 영문 문서를 참고하세요. 
 

Advanced settings configuration in WSL

A guide to the wsl.conf and .wslconfig files used for configuring settings when running multiple Linux distributions on Windows Subsystem for Linux.

learn.microsoft.com

 

How to configure memory limits in WSL2

One of the downsides to building machine learning models is that you need quite a bit of power in your machine. I've just upgraded my home desktop that I use for side projects and experiments to 64GB of memory because it was clearly no longer up to the tas

fizzylogic.nl