yarn 으로 package 를 설치하는데 에러가 발생했다

 

에러 전문

Progress: resolved 763, reused 737, downloaded 0, added 739, done
node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass: Running install script, done in 260ms
node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass: Running postinstall script, failed in 366ms
.../node_modules/node-sass postinstall$ node scripts/build.js
│ Binary found at /Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass/vendor/darwin-arm64-108/binding.node
│ Testing binary
│ Binary has a problem: Error: dlopen(/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass/vendor/darwin-arm64-108/binding.node, 0x0001): tried: '/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sa…
│     at Module._extensions..node (node:internal/modules/cjs/loader:1338:18)
│     at Module.load (node:internal/modules/cjs/loader:1117:32)
│     at Module._load (node:internal/modules/cjs/loader:958:12)
│     at Module.require (node:internal/modules/cjs/loader:1141:19)
│     at require (node:internal/modules/cjs/helpers:110:18)
│     at module.exports (/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass/lib/binding.js:19:10)
│     at Object.<anonymous> (/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass/lib/index.js:13:35)
│     at Module._compile (node:internal/modules/cjs/loader:1254:14)
│     at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
│     at Module.load (node:internal/modules/cjs/loader:1117:32) {
│   code: 'ERR_DLOPEN_FAILED'
│ }
│ Building the binary locally
│ Building: /usr/local/bin/node /Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
│ gyp info it worked if it ends with ok
│ gyp verb cli [
│ gyp verb cli   '/usr/local/bin/node',
│ gyp verb cli   '/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/bin/node-gyp.js',
│ gyp verb cli   'rebuild',
│ gyp verb cli   '--verbose',
│ gyp verb cli   '--libsass_ext=',
│ gyp verb cli   '--libsass_cflags=',
│ gyp verb cli   '--libsass_ldflags=',
│ gyp verb cli   '--libsass_library='
│ gyp verb cli ]
│ gyp info using node-gyp@8.4.1
│ gyp info using node@18.16.0 | darwin | arm64
│ gyp verb command rebuild []
│ gyp verb command clean []
│ gyp verb clean removing "build" directory
│ gyp verb command configure []
│ gyp verb find Python Python is not set from command line or npm configuration
│ gyp verb find Python Python is not set from environment variable PYTHON
│ gyp verb find Python checking if "python3" can be used
│ gyp verb find Python - executing "python3" to get executable path
│ gyp verb find Python - executable path is "/Library/Frameworks/Python.framework/Versions/3.12/bin/python3"
│ gyp verb find Python - executing "/Library/Frameworks/Python.framework/Versions/3.12/bin/python3" to get version
│ gyp verb find Python - version is "3.12.2"
│ gyp info find Python using Python version 3.12.2 found at "/Library/Frameworks/Python.framework/Versions/3.12/bin/python3"
│ gyp verb get node dir no --target version specified, falling back to host node version: 18.16.0
│ gyp verb command install [ '18.16.0' ]
│ gyp verb install input version string "18.16.0"
│ gyp verb install installing version: 18.16.0
│ gyp verb install --ensure was passed, so won't reinstall if already installed
│ gyp verb install version is already installed, need to check "installVersion"
│ gyp verb got "installVersion" 11
│ gyp verb needs "installVersion" 9
│ gyp verb install version is good
│ gyp verb get node dir target node version installed: 18.16.0
│ gyp verb build dir attempting to create "build" dir: /Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass/build
│ gyp verb build dir "build" dir needed to be created? Yes
│ gyp verb build/config.gypi creating config file
│ gyp verb build/config.gypi writing out config file: /Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass/build/config.gypi
│ gyp verb config.gypi checking for gypi file: /Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass/config.gypi
│ gyp verb common.gypi checking for gypi file: /Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass/common.gypi
│ gyp verb gyp gyp format was not specified; forcing "make"
│ gyp info spawn /Library/Frameworks/Python.framework/Versions/3.12/bin/python3
│ gyp info spawn args [
│ gyp info spawn args   '/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/gyp/gyp_main.py',
│ gyp info spawn args   'binding.gyp',
│ gyp info spawn args   '-f',
│ gyp info spawn args   'make',
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass/build/config.gypi',
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/addon.gypi',
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/Users/mik_a/Library/Caches/node-gyp/18.16.0/include/node/common.gypi',
│ gyp info spawn args   '-Dlibrary=shared_library',
│ gyp info spawn args   '-Dvisibility=default',
│ gyp info spawn args   '-Dnode_root_dir=/Users/mik_a/Library/Caches/node-gyp/18.16.0',
│ gyp info spawn args   '-Dnode_gyp_dir=/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp',
│ gyp info spawn args   '-Dnode_lib_file=/Users/mik_a/Library/Caches/node-gyp/18.16.0/<(target_arch)/node.lib',
│ gyp info spawn args   '-Dmodule_root_dir=/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass',
│ gyp info spawn args   '-Dnode_engine=v8',
│ gyp info spawn args   '--depth=.',
│ gyp info spawn args   '--no-parallel',
│ gyp info spawn args   '--generator-output',
│ gyp info spawn args   'build',
│ gyp info spawn args   '-Goutput_dir=.'
│ gyp info spawn args ]
│ Traceback (most recent call last):
│   File "/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/gyp/gyp_main.py", line 42, in <module>
│     import gyp  # noqa: E402
│     ^^^^^^^^^^
│   File "/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 9, in <module>
│     import gyp.input
│   File "/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in <module>
│     from distutils.version import StrictVersion
│ ModuleNotFoundError: No module named 'distutils'
│ gyp ERR! configure error 
│ gyp ERR! stack Error: `gyp` failed with exit code: 1
│ gyp ERR! stack     at ChildProcess.onCpExit (/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/lib/configure.js:259:16)
│ gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
│ gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
│ gyp ERR! System Darwin 22.4.0
│ gyp ERR! command "/usr/local/bin/node" "/Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_li…
│ gyp ERR! cwd /Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass
│ gyp ERR! node -v v18.16.0
│ gyp ERR! node-gyp -v v8.4.1
│ gyp ERR! not ok 
│ Build failed with error code: 1
└─ Failed in 366ms at /Users/mik_a/Desktop/dev/ezerp/node_modules/.pnpm/node-sass@9.0.0/node_modules/node-sass
 ELIFECYCLE  Command failed with exit code 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

 

 

node-gyp 에서 python 으로 뭔가를 하는가보다.

거기서 distutils 라는 모듈이 없다고 떴다.

 

검색해보니 setuptools 패키지를 업그레이드 하라고 해서 해줬다.

python3 -m pip install --upgrade setuptools

 

 

이후엔 설치가 잘 됐다.

개발 당시에는 localhost:3000 의 주소를 이용해서 nodejs socketio 서버랑 통신했었다.

이후 서버에 올리고 포트번호가 아닌 cname 을 통해서 통신하기 위해서 nginx 세팅을 했다.

 

server {
        listen 443 ssl;

        ssl_certificate /etc/letsencrypt/live/my.co.kr/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/my.co.kr/privkey.pem;

        server_name api.my.co.kr;
        access_log /var/log/nginx/my-access.log;
        error_log /var/log/nginx/my-access.log;

        location / {
                proxy_pass https://my.co.kr:3000;
        }
 }

이렇게 api.my.co.kr 을 3000번 포트로 연결해놨다.

그런데 아무리 해도 안되길래 

뭐지? ssl 세팅을 잘못했나? 하면서 삽질을 엄청했다.

그러다 그냥 클라이언트에서 3000번 포트 (https://my.co.kr:3000) 로 연결하니 바로 되길래 nginx 쪽이 문제구나 싶었다.

 

https://socket.io/docs/v3/reverse-proxy/ 

 

검색하니 바로 나오더라

해결방법은

 

server {
        listen 443 ssl;

        ssl_certificate /etc/letsencrypt/live/my.co.kr/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/my.co.kr/privkey.pem;

        server_name api.my.co.kr;
        access_log /var/log/nginx/my-access.log;
        error_log /var/log/nginx/my-access.log;

        location / {
                proxy_pass https://my.co.kr:3000;
        }

		# 아래 부분
        location /socket.io/ {
              proxy_pass https://my.co.kr:3000/socket.io/;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header Host $host;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
    }
 }

 

코드 블럭의 아래 location /socket.io 부분을 추가해주면 된다.

 

nginx 로그를 봤을 때 socketio 를 통신하면서 해당 주소의 /socket.io 와 통신해야하는데 이 부분이 문제가 생겨서 그런 듯 하다.

pytorch 를 사용하는데 세팅을 자주 하는게 아니다 보니 매번 까먹어서 기록할려는 글.

windows용 도커도 조만간 만들어야겠다.

 

1. cuda 설치

 

https://developer.nvidia.com/cuda-11-7-0-download-archive?target_os=Windows&target_arch=x86_64&target_version=10 

 

CUDA Toolkit 11.7 Downloads

Resources CUDA Documentation/Release NotesMacOS Tools Training Sample Code Forums Archive of Previous CUDA Releases FAQ Open Source PackagesSubmit a BugTarball and Zip Archive Deliverables

developer.nvidia.com

현재까진 pytorch 가 cuda 11.7 버전까지 지원하는 듯 하여 최신버전인 12.0 대신 11.7 버전을 설치했다.

 

2. cuDNN 설치 (로그인 필요)

 

https://developer.nvidia.com/rdp/cudnn-archive

 

cuDNN Archive

Download releases from the GPU-accelerated primitive library for deep neural networks.

developer.nvidia.com

 

cuDNN 설치.11.x 버전을 설치하면 된다

설치된 파일을 cuda 설치한 폴더로 옮긴다

 

3. Pytorch 설치

pytorch가 설치되어있다면 pytorch 버전 먼저 확인한다

import torch
print(torch.__version__)
# 1.13.0+cpu

print(torch.cuda.is_available())
# False

보니깐 cpu 버전으로 설치되어 있더라... 그래서 cuda 사용이 불가능 했었다.

일단 uninstall 해주고,

 

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117

 

해당 커맨드로 11.7 버전용 pytorch 를 설치해줬다.

 

import torch
print(torch.__version__)
# 1.13.0+cu117

print(torch.cuda.is_available())
# True

그 다음 버전을 확인하니 cuda 버전으로 뜬다.

npm i -g npm-check-updates
ncu -u
npm install

 

알아서 최신 버전으로 업데이트 된다

nodejs express 서버를 로컬에선 오차없이 실행되다가 서버에만 올리면 이상해지길래 timezone 문제라고 생각이 들었다.

 

sudo rm /etc/localtime
sudo ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime

이후 nodejs 재실행하니 제대로 동작했다.

+ Recent posts