Skip to content

Commit

Permalink
update setup to check version and install pytorch by cuda
Browse files Browse the repository at this point in the history
  • Loading branch information
creeponsky committed Apr 9, 2023
1 parent ba74b47 commit dea77ef
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 4 deletions.
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

1. **创建本地虚拟环境并安装所需库:**

- Windows:直接运行 `setup.bat`
- Windows:在**开启管理员**命令行的情况下直接运行 `setup.bat`
> ⚠️ 注意:windows会直接在bat中安装pytorch2.0 + cu118,如果你的显卡不支持请自行更换版本或者选择 +cpu版本而并非cuda
- macOS / Unix:
```bash
chmod +x setup.sh
Expand Down
37 changes: 36 additions & 1 deletion setup.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
@echo off

echo Checking Python, pip, Node.js

python --version 2>&1
if errorlevel 1 (
echo Error: Python is not installed or not in the PATH.
pause
exit /b 1
)

pip --version 2>&1
if errorlevel 1 (
echo Error: pip is not installed or not in the PATH.
pause
exit /b 1
)

node --version 2>&1
if errorlevel 1 (
echo Error: Node.js is not installed or not in the PATH.
pause
exit /b 1
)

echo All dependencies are present.

echo Installing virtualenv
pip install --user virtualenv

Expand All @@ -11,7 +36,15 @@ call env\Scripts\activate.bat

echo Installing Python dependencies
pip install git+https://github.com/facebookresearch/segment-anything.git
pip install opencv-python pycocotools matplotlib onnxruntime onnx gradio flask werkzeug torch torchvision torchaudio
pip install opencv-python
pip install pycocotools
pip install matplotlib
pip install onnxruntime
pip install onnx
pip install gradio
pip install flask
pip install werkzeug
pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 --extra-index-url https://download.pytorch.org/whl/cu118

echo Installing Node.js dependencies
npm install -g typescript
Expand All @@ -21,3 +54,5 @@ echo Compiling TypeScript to JavaScript
tsc

echo Setup complete

pause
34 changes: 32 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
#!/bin/bash

echo "Checking Python, pip, Node.js"

python --version
if [ $? -ne 0 ]; then
echo "Error: Python is not installed or not in the PATH."
exit 1
fi

pip --version
if [ $? -ne 0 ]; then
echo "Error: pip is not installed or not in the PATH."
exit 1
fi

node --version
if [ $? -ne 0 ]; then
echo "Error: Node.js is not installed or not in the PATH."
exit 1
fi

echo "All dependencies are present."

echo "Installing virtualenv"
pip install --user virtualenv

echo "Creating virtual environment"
python3 -m venv env
python -m venv env

echo "Activating virtual environment"
source env/bin/activate

echo "Installing Python dependencies"
pip install git+https://github.com/facebookresearch/segment-anything.git
pip install opencv-python pycocotools matplotlib onnxruntime onnx gradio flask werkzeug torch torchvision torchaudio
pip install opencv-python
pip install pycocotools
pip install matplotlib
pip install onnxruntime
pip install onnx
pip install gradio
pip install flask
pip install werkzeug
pip install torch torchvision

echo "Installing Node.js dependencies"
npm install -g typescript
Expand Down

0 comments on commit dea77ef

Please sign in to comment.