Advertisement
Guest User

Untitled

a guest
Apr 17th, 2025
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.85 KB | None | 0 0
  1. @echo off
  2. setlocal enabledelayedexpansion
  3.  
  4. echo FramePack Installer
  5. echo =================
  6. echo.
  7.  
  8. REM Check if Python is installed
  9. python --version >nul 2>&1
  10. if %errorlevel% neq 0 (
  11. echo Python is not installed or not in PATH.
  12. echo Please install Python 3.10+ from https://www.python.org/downloads/
  13. echo Make sure to check "Add Python to PATH" during installation.
  14. echo.
  15. pause
  16. exit /b 1
  17. )
  18.  
  19. REM Check Python version (need 3.10+)
  20. for /f "tokens=2" %%I in ('python --version 2^>^&1') do (
  21. set pyver=%%I
  22. )
  23. for /f "tokens=1,2 delims=." %%a in ("%pyver%") do (
  24. set major=%%a
  25. set minor=%%b
  26. )
  27. if %major% LSS 3 (
  28. echo Python version %pyver% is too old. FramePack requires Python 3.10+
  29. pause
  30. exit /b 1
  31. )
  32. if %major% EQU 3 if %minor% LSS 10 (
  33. echo Python version %pyver% is too old. FramePack requires Python 3.10+
  34. pause
  35. exit /b 1
  36. )
  37.  
  38. REM Set up repo directory
  39. set REPO_DIR=%~dp0FramePack
  40. if not exist "%REPO_DIR%" (
  41. echo Cloning FramePack repository...
  42. git clone https://github.com/lllyasviel/FramePack.git "%REPO_DIR%"
  43. if %errorlevel% neq 0 (
  44. echo Failed to clone repository. Make sure git is installed.
  45. echo Install git from https://git-scm.com/downloads
  46. pause
  47. exit /b 1
  48. )
  49. ) else (
  50. echo FramePack repository already exists.
  51. echo Updating repository...
  52. cd "%REPO_DIR%"
  53. git pull
  54. cd ..
  55. )
  56.  
  57. REM Create virtual environment
  58. set VENV_DIR=%~dp0framepack_venv
  59. if not exist "%VENV_DIR%" (
  60. echo Creating virtual environment...
  61. python -m venv "%VENV_DIR%"
  62. if %errorlevel% neq 0 (
  63. echo Failed to create virtual environment.
  64. pause
  65. exit /b 1
  66. )
  67. )
  68.  
  69. REM Activate virtual environment and install dependencies
  70. echo Installing dependencies...
  71. call "%VENV_DIR%\Scripts\activate.bat"
  72.  
  73. REM Install PyTorch with CUDA support (using available versions)
  74. echo Installing PyTorch and dependencies...
  75. python -m pip install --upgrade pip
  76.  
  77. echo Installing PyTorch packages (latest available for CUDA 12.6)...
  78. pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
  79.  
  80. echo Installing common dependencies...
  81. pip install numpy pillow
  82.  
  83. REM Check if torchvision is installed correctly
  84. python -c "import torchvision; print('Torchvision version:', torchvision.__version__)"
  85. if %errorlevel% neq 0 (
  86. echo Warning: Torchvision installation verification failed.
  87. echo Attempting alternative installation...
  88. pip install torchvision --force-reinstall --no-deps --index-url https://download.pytorch.org/whl/cu126
  89. python -c "import torchvision"
  90. if %errorlevel% neq 0 (
  91. echo Failed to install torchvision. Please check your Python environment.
  92. pause
  93. exit /b 1
  94. )
  95. )
  96.  
  97. REM Install requirements
  98. cd "%REPO_DIR%"
  99.  
  100. echo Checking for requirements.txt...
  101. if not exist requirements.txt (
  102. echo Warning: requirements.txt not found in the repository!
  103. echo Installing commonly needed packages instead...
  104. ) else (
  105. echo Installing requirements from requirements.txt...
  106. pip install -r requirements.txt
  107. if %errorlevel% neq 0 (
  108. echo Warning: Some packages in requirements.txt could not be installed.
  109. echo Continuing with installation of key packages...
  110. )
  111. )
  112.  
  113. REM Install common dependencies that might be needed
  114. echo Installing additional dependencies...
  115. pip install --upgrade gradio diffusers transformers safetensors
  116. pip install --upgrade accelerate einops kornia opencv-python
  117. pip install --upgrade huggingface_hub
  118. pip install --upgrade scipy scikit-image scikit-learn
  119. pip install --upgrade ftfy
  120.  
  121. REM Try to install xformers if possible
  122. echo Attempting to install xformers...
  123. pip install --upgrade xformers --index-url https://download.pytorch.org/whl/cu126
  124. if %errorlevel% neq 0 (
  125. echo xformers installation failed, but this is optional.
  126. echo FramePack will still work without it.
  127. )
  128.  
  129.  
  130. REM Create a launcher batch file
  131. set LAUNCHER=%~dp0run_framepack.bat
  132.  
  133. echo @echo off > "%LAUNCHER%"
  134. echo setlocal enabledelayedexpansion >> "%LAUNCHER%"
  135. echo title FramePack >> "%LAUNCHER%"
  136. echo. >> "%LAUNCHER%"
  137. echo echo ========================================== >> "%LAUNCHER%"
  138. echo echo FramePack Launcher >> "%LAUNCHER%"
  139. echo echo ========================================== >> "%LAUNCHER%"
  140. echo echo. >> "%LAUNCHER%"
  141.  
  142. echo REM Activate virtual environment >> "%LAUNCHER%"
  143. echo call "%VENV_DIR%\Scripts\activate.bat" >> "%LAUNCHER%"
  144. echo. >> "%LAUNCHER%"
  145.  
  146. echo REM Basic dependency check >> "%LAUNCHER%"
  147. echo echo Checking dependencies... >> "%LAUNCHER%"
  148. echo python -c "import torch" 2^>nul >> "%LAUNCHER%"
  149. echo if %%errorlevel%% neq 0 ( >> "%LAUNCHER%"
  150. echo echo Error: PyTorch is not installed correctly. >> "%LAUNCHER%"
  151. echo echo Please run install_framepack.bat again to fix dependencies. >> "%LAUNCHER%"
  152. echo pause >> "%LAUNCHER%"
  153. echo exit /b 1 >> "%LAUNCHER%"
  154. echo ) >> "%LAUNCHER%"
  155. echo. >> "%LAUNCHER%"
  156.  
  157. echo REM Check for CUDA availability >> "%LAUNCHER%"
  158. echo python -c "import torch; print('CUDA Available:', torch.cuda.is_available()); print('CUDA Version:', torch.version.cuda if torch.cuda.is_available() else 'N/A'); print('GPU Model:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'No GPU detected')" >> "%LAUNCHER%"
  159. echo if %%errorlevel%% neq 0 ( >> "%LAUNCHER%"
  160. echo echo Warning: Could not verify CUDA availability. >> "%LAUNCHER%"
  161. echo ) >> "%LAUNCHER%"
  162. echo. >> "%LAUNCHER%"
  163.  
  164. echo cd "%REPO_DIR%" >> "%LAUNCHER%"
  165. echo echo. >> "%LAUNCHER%"
  166. echo echo Starting FramePack... >> "%LAUNCHER%"
  167. echo echo. >> "%LAUNCHER%"
  168. echo echo If the application fails to start, check these common issues: >> "%LAUNCHER%"
  169. echo echo - Make sure you have an NVIDIA GPU with CUDA support >> "%LAUNCHER%"
  170. echo echo - At least 6GB of VRAM is recommended >> "%LAUNCHER%"
  171. echo echo - Try running the installer again if modules are missing >> "%LAUNCHER%"
  172. echo echo. >> "%LAUNCHER%"
  173.  
  174. echo python demo_gradio.py %%* >> "%LAUNCHER%"
  175. echo. >> "%LAUNCHER%"
  176. echo if %%errorlevel%% neq 0 ( >> "%LAUNCHER%"
  177. echo echo. >> "%LAUNCHER%"
  178. echo echo FramePack exited with an error. >> "%LAUNCHER%"
  179. echo echo. >> "%LAUNCHER%"
  180. echo echo Possible solutions: >> "%LAUNCHER%"
  181. echo echo 1. Try reinstalling by running install_framepack.bat >> "%LAUNCHER%"
  182. echo echo 2. Check if your GPU meets the requirements >> "%LAUNCHER%"
  183. echo echo 3. For more help, visit: https://github.com/lllyasviel/FramePack >> "%LAUNCHER%"
  184. echo ) else ( >> "%LAUNCHER%"
  185. echo echo. >> "%LAUNCHER%"
  186. echo echo FramePack closed successfully. >> "%LAUNCHER%"
  187. echo ) >> "%LAUNCHER%"
  188. echo. >> "%LAUNCHER%"
  189. echo pause >> "%LAUNCHER%"
  190.  
  191. REM Create a minimal test script to verify imports
  192. set TEST_SCRIPT=%TEMP%\test_imports.py
  193. echo import torch > "%TEST_SCRIPT%"
  194. echo import torchvision >> "%TEST_SCRIPT%"
  195. echo print("PyTorch version:", torch.__version__) >> "%TEST_SCRIPT%"
  196. echo print("Torchvision version:", torchvision.__version__) >> "%TEST_SCRIPT%"
  197. echo try: >> "%TEST_SCRIPT%"
  198. echo import diffusers >> "%TEST_SCRIPT%"
  199. echo print("Diffusers version:", diffusers.__version__) >> "%TEST_SCRIPT%"
  200. echo except ImportError: >> "%TEST_SCRIPT%"
  201. echo print("WARNING: diffusers not installed") >> "%TEST_SCRIPT%"
  202. echo try: >> "%TEST_SCRIPT%"
  203. echo import transformers >> "%TEST_SCRIPT%"
  204. echo print("Transformers version:", transformers.__version__) >> "%TEST_SCRIPT%"
  205. echo except ImportError: >> "%TEST_SCRIPT%"
  206. echo print("WARNING: transformers not installed") >> "%TEST_SCRIPT%"
  207. echo try: >> "%TEST_SCRIPT%"
  208. echo import gradio >> "%TEST_SCRIPT%"
  209. echo print("Gradio version:", gradio.__version__) >> "%TEST_SCRIPT%"
  210. echo except ImportError: >> "%TEST_SCRIPT%"
  211. echo print("WARNING: gradio not installed") >> "%TEST_SCRIPT%"
  212.  
  213. echo.
  214. echo Verifying installation...
  215. python "%TEST_SCRIPT%"
  216. set VERIFY_RESULT=%errorlevel%
  217.  
  218. echo.
  219. if %VERIFY_RESULT% neq 0 (
  220. echo ⚠️ Warning: Some dependencies may not be installed correctly.
  221. echo.
  222. echo If you encounter issues running FramePack, try these steps:
  223. echo 1. Make sure you have an NVIDIA GPU with CUDA support
  224. echo 2. Try running the installer again
  225. echo 3. If problems persist, install packages manually:
  226. echo pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
  227. echo pip install gradio diffusers transformers
  228. echo.
  229. ) else (
  230. echo ✅ Core dependencies verified successfully!
  231. )
  232.  
  233. echo Installation complete!
  234. echo.
  235. echo To run FramePack, use the run_framepack.bat file or run:
  236. echo %LAUNCHER%
  237. echo.
  238. echo You can pass additional parameters like --share for public link:
  239. echo %LAUNCHER% --share
  240. echo.
  241. echo If you encounter any issues, please check the FramePack GitHub repository:
  242. echo https://github.com/lllyasviel/FramePack
  243. echo.
  244. pause
  245.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement