ashawkey / stable-dreamfusion

Text-to-3D & Image-to-3D & Mesh Exportation with NeRF + Diffusion.
Apache License 2.0
8.33k stars 734 forks source link

Is a WSL2 + nvidia-docker environment supported? #38

Open s024 opened 2 years ago

s024 commented 2 years ago

Hello,

I tried to install stable-dreamfusion in a WSL2 + nvidia-docker environment, the following error occurred. The procedure of Build image in Docker/README.md has been executed.

 => CACHED [13/16] RUN pip3 install git+https://github.com/NVlabs/nvdiffrast/                                      0.0s
 => ERROR [14/16] RUN pip3 install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch        18.3s
------
 > [14/16] RUN pip3 install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch:
#17 1.107 Collecting git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
#17 1.107   Cloning https://github.com/NVlabs/tiny-cuda-nn/ to /tmp/pip-req-build-1p1uv4so
#17 1.107   Running command git clone -q https://github.com/NVlabs/tiny-cuda-nn/ /tmp/pip-req-build-1p1uv4so
#17 6.520   Running command git submodule update --init --recursive -q
#17 18.23     ERROR: Command errored out with exit status 1:
#17 18.23      command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-1p1uv4so/bindings/torch/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-1p1uv4so/bindings/torch/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-req-build-1p1uv4so/bindings/torch/pip-egg-info
#17 18.23          cwd: /tmp/pip-req-build-1p1uv4so/bindings/torch
#17 18.23     Complete output (7 lines):
#17 18.23     Traceback (most recent call last):
#17 18.23       File "<string>", line 1, in <module>
#17 18.23       File "/tmp/pip-req-build-1p1uv4so/bindings/torch/setup.py", line 30, in <module>
#17 18.23         raise EnvironmentError("Unknown compute capability. Specify the target compute capabilities in the TCNN_CUDA_ARCHITECTURES environment variable or install PyTorch with the CUDA backend to detect it automatically.")
#17 18.23     OSError: Unknown compute capability. Specify the target compute capabilities in the TCNN_CUDA_ARCHITECTURES environment variable or install PyTorch with the CUDA backend to detect it automatically.
#17 18.23     No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
#17 18.23     Building PyTorch extension for tiny-cuda-nn version 1.6
#17 18.23     ----------------------------------------
#17 18.31 ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
------
executor failed running [/bin/sh -c pip3 install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch]: exit code: 1
avaleriani commented 2 years ago

Having the same issue, I managed to advance some steps after lots of debugging but ended up with an error where memory could not be allocated on the GPU, despite its availability.

s024 commented 2 years ago

Thanks for the reply,

First, I will debug it and see if it works in my environment.

pureexe commented 2 years ago

Maybe out of the topic for WSL.

But I'm running this repo on Windows by

1. Install Visual studio with "Desktop development with C++"

image

2. Once you have finished installing Visual studio. Windows Terminal (wt.exe) will introduce a new option, Developer PowerShell for VS 20xx please switch to this shell instead of your regular shell for using its build tools.

image

3. follow the installation guide on the README.txt.

pip install -r requirements.txt
pip install git+https://github.com/NVlabs/nvdiffrast/
pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
pip install git+https://github.com/openai/CLIP.git

4. To install an extension such as raymarching. Windows won't recognize bash. So, you have to input its content line by line.

pip install ./raymarching
pip install ./shencoder
pip install ./freqencoder
pip install ./gridencoder

5. Done. Fill your prompt and run!

image

You will get output video after 100 epochs or depend on your --iters parameter

https://user-images.githubusercontent.com/1303847/196019884-bdfe16a7-6aaf-431b-99f7-fb692c5cab79.mp4

s024 commented 2 years ago

Thanks, pureexe.

I'll try your method.

y0himba commented 2 years ago

Setup fails on NvDiffrast:

(base) PS C:\stable-diffusion\stable-dreamfusion> pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
Collecting git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
  Cloning https://github.com/NVlabs/tiny-cuda-nn/ to c:\users\y0himba\appdata\local\temp\pip-req-build-9zt_j75u
  Running command git clone --filter=blob:none --quiet https://github.com/NVlabs/tiny-cuda-nn/ 'C:\Users\y0himba\AppData\Local\Temp\pip-req-build-9zt_j75u'
  Resolved https://github.com/NVlabs/tiny-cuda-nn/ to commit 90af227bfc96549edd96937166f63639e46ba8aa
  Running command git submodule update --init --recursive -q
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\y0himba\AppData\Local\Temp\pip-req-build-9zt_j75u\bindings/torch\setup.py", line 3, in <module>
          import torch
        File "C:\ProgramData\Miniconda3\lib\site-packages\torch\__init__.py", line 129, in <module>
          raise err
      OSError: [WinError 127] The specified procedure could not be found. Error loading "C:\ProgramData\Miniconda3\lib\site-packages\torch\lib\caffe2_detectron_ops_gpu.dll" or one of its dependencies.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
s024 commented 2 years ago

I also got an error in the same place. I use CUDA version 11.7 and my graphics card is RTX A4000. Windows OS version is 11 21H2.

PS D:\stable-dreamfusion> pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
Collecting git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
  Cloning https://github.com/NVlabs/tiny-cuda-nn/ to c:\users\shin\appdata\local\temp\pip-req-build-cykrofi0
  Running command git clone --filter=blob:none --quiet https://github.com/NVlabs/tiny-cuda-nn/ 'C:\Users\shin\AppData\Local\Temp\pip-req-build-cykrofi0'
  Resolved https://github.com/NVlabs/tiny-cuda-nn/ to commit 90af227bfc96549edd96937166f63639e46ba8aa
  Running command git submodule update --init --recursive -q
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\shin\AppData\Local\Temp\pip-req-build-cykrofi0\bindings/torch\setup.py", line 30, in <module>
          raise EnvironmentError("Unknown compute capability. Specify the target compute capabilities in the TCNN_CUDA_ARCHITECTURES environment variable or install PyTorch with the CUDA backend to detect it automatically.")
      OSError: Unknown compute capability. Specify the target compute capabilities in the TCNN_CUDA_ARCHITECTURES environment variable or install PyTorch with the CUDA backend to detect it automatically.
      No CUDA runtime is found, using CUDA_HOME='C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7'
      Building PyTorch extension for tiny-cuda-nn version 1.6
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
flobotics commented 2 years ago

hi @pureexe , i read on the net, that the big difference between powershell and developer powershell are the auto set environment variables. Could you post the env vars of your developer powershell, seemed like your using an enterprise version of visual studio.

thx

s024 commented 2 years ago

Sorry for the Japanese article, By deleting the line of tiny-cuda-nn install from Dockerfile, I found stable-dreamfusion working properly in WSL2 + nvidia-docker environment. If tiny-cuda-nn option is not used, I do not see any problem.

https://qiita.com/Aster_ideatech/items/772c27fe3056eb3e7f6b?utm_campaign=post_article&utm_medium=twitter&utm_source=twitter_share

y0himba commented 2 years ago

I've got it down to installing raymarching, even though I am unable to install tncc. Now I am getting this error. Where can I insert set DISTUTILS_USE_SDK=1 so that I won't need to type it every time?

 UserWarning: It seems that the VC environment is activated but DISTUTILS_USE_SDK is not set.This may lead to multiple activations of the VC env.Please set `DISTUTILS_USE_SDK=1` and try again.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> raymarching
pureexe commented 2 years ago

@flobotics No, i use Community version 2022,

Could you post the env vars of your developer powershell

Sure,

**********************************************************************
** Visual Studio 2022 Developer PowerShell v17.3.6
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
PS C:\Program Files\Microsoft Visual Studio\2022\Community> gci env:* | sort-object name

Name                           Value
----                           -----
__DOTNET_ADD_64BIT             1
__DOTNET_PREFERRED_BITNESS     64
__VSCMD_PREINIT_PATH           C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.15.2875.0_x64__8wekyb3d8bbwe;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\libnvvp;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libnvvp;C:\Wi...
ALLUSERSPROFILE                C:\ProgramData
APPDATA                        C:\Users\pakkapon\AppData\Roaming
CommandPromptType              Native
CommonProgramFiles             C:\Program Files\Common Files
CommonProgramFiles(x86)        C:\Program Files (x86)\Common Files
CommonProgramW6432             C:\Program Files\Common Files
COMPUTERNAME                   PIE
ComSpec                        C:\Windows\system32\cmd.exe
CUDA_PATH                      C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8
CUDA_PATH_V11_7                C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7
CUDA_PATH_V11_8                C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8
DevEnvDir                      C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\
DISTUTILS_USE_SDK              1
DriverData                     C:\Windows\System32\Drivers\DriverData
ExtensionSdkDir                C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs
EXTERNAL_INCLUDE               C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\ATLMFC\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt;C:\Program ...
FPS_BROWSER_APP_PROFILE_STRING Internet Explorer
FPS_BROWSER_USER_PROFILE_ST... Default
Framework40Version             v4.0
FrameworkDir                   C:\Windows\Microsoft.NET\Framework64\
FrameworkDir64                 C:\Windows\Microsoft.NET\Framework64\
FrameworkVersion               v4.0.30319
FrameworkVersion64             v4.0.30319
HOMEDRIVE                      C:
HOMEPATH                       \Users\pakkapon
INCLUDE                        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\ATLMFC\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt;C:\Program ...
LIB                            C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\ATLMFC\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\lib\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.19041.0\\um\x64
LIBPATH                        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\ATLMFC\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\lib\x86\store\references;C:\Program Files (x86)\Windows Kits\10\UnionMetad...
LOCALAPPDATA                   C:\Users\pakkapon\AppData\Local
LOGONSERVER                    \\PIE
NUMBER_OF_PROCESSORS           24
NVTOOLSEXT_PATH                C:\Program Files\NVIDIA Corporation\NvToolsExt\
OneDrive                       C:\Users\pakkapon\OneDrive - Vidyasirimedhi Institue of Science and Technology
OneDriveCommercial             C:\Users\pakkapon\OneDrive - Vidyasirimedhi Institue of Science and Technology
OneDriveConsumer               C:\Users\pakkapon\OneDrive
OS                             Windows_NT
Path                           C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\VCPackages;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files\Microsoft Visual Studio\2022\Community\C...
PATHEXT                        .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL
POWERSHELL_DISTRIBUTION_CHA... MSI:Windows 10 Pro
PROCESSOR_ARCHITECTURE         AMD64
PROCESSOR_IDENTIFIER           AMD64 Family 25 Model 33 Stepping 0, AuthenticAMD
PROCESSOR_LEVEL                25
PROCESSOR_REVISION             2100
ProgramData                    C:\ProgramData
ProgramFiles                   C:\Program Files
ProgramFiles(x86)              C:\Program Files (x86)
ProgramW6432                   C:\Program Files
PROMPT                         $P$G
PSModulePath                   C:\Users\pakkapon\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC                         C:\Users\Public
SystemDrive                    C:
SystemRoot                     C:\Windows
TEMP                           C:\Users\pakkapon\AppData\Local\Temp
TMP                            C:\Users\pakkapon\AppData\Local\Temp
UCRTVersion                    10.0.19041.0
UniversalCRTSdkDir             C:\Program Files (x86)\Windows Kits\10\
USERDOMAIN                     PIE
USERDOMAIN_ROAMINGPROFILE      PIE
USERNAME                       pakkapon
USERPROFILE                    C:\Users\pakkapon
VCIDEInstallDir                C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\
VCINSTALLDIR                   C:\Program Files\Microsoft Visual Studio\2022\Community\VC\
VCToolsInstallDir              C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\
VCToolsRedistDir               C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.32.31326\
VCToolsVersion                 14.33.31629
VisualStudioVersion            17.0
VS170COMNTOOLS                 C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\
VSCMD_ARG_app_plat             Desktop
VSCMD_ARG_HOST_ARCH            x64
VSCMD_ARG_TGT_ARCH             x64
VSCMD_VER                      17.3.6
VSINSTALLDIR                   C:\Program Files\Microsoft Visual Studio\2022\Community\
windir                         C:\Windows
WindowsLibPath                 C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.19041.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.19041.0
WindowsSdkBinPath              C:\Program Files (x86)\Windows Kits\10\bin\
WindowsSdkDir                  C:\Program Files (x86)\Windows Kits\10\
WindowsSDKLibVersion           10.0.19041.0\
WindowsSdkVerBinPath           C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\
WindowsSDKVersion              10.0.19041.0\
WSLENV                         WT_SESSION::WT_PROFILE_ID
WT_PROFILE_ID                  {8ff95d74-9b2b-5f3d-aeab-904248fe598f}
WT_SESSION                     7dc5142d-dd7e-45e2-970f-b7a307102046

PS C:\Program Files\Microsoft Visual Studio\2022\Community>
pureexe commented 2 years ago

@y0himba

Open Settings (Press WinKey+i on the keyboard) and then select System then About and then Advanced System Setting

image

Then, go to Advanced tab, and then Environment Variables

image

Then, go to System variable and press New..

image

Then, type variable name DISTUTILS_USE_SDK and varaible value 1

image

Reload the shell should be enable the variable. But I recommend you to Restart the windows because sometimes it doesn't work.

image

pureexe commented 2 years ago

@s024 Your error said No CUDA runtime is found

Could you run nvcc -V in developer shell? Is that print out the version of nvcc ? if yes, is it 11.7? (By the way, i'm using 11.8)

image

s024 commented 2 years ago

@pureexe In my environment, nvcc is found and version is 11.7. Should I upgrade it up to version 11.8?

pureexe commented 2 years ago

11.7 should work fine. I don't know why is said No CUDA runtime is found when nvcc is actually there.

s024 commented 2 years ago

Just in case, I upgraded to 11.8, but the No CUDA runtime is found problem was not resolved. In this case, I have found that this probelm is due to compatibility issues with tiny-cuda-nn rather than stable-dreamfusion, so I will not use tiny-cuda-nn option.

y0himba commented 2 years ago

Do you have the CUDA variables in your path? image Clipboard01

s024 commented 2 years ago

@y0himba I added CUDA variables as you said, but I got the same error message.

y0himba commented 2 years ago

@y0himba I added CUDA variables as you said, but I got the same error message.

How many Python installs are on your computer? Do you have for instance 32bit and 64bit Python installs? Miniconda and Anaconda? Would you mind showing me your environment variables?

s024 commented 2 years ago

I now only install 64bit Python v3.10.8 in my PC. Neither Miniconda nor Anaconda is used. I am Japanese and use Windows 11 Japanese environment, so path separator is not backslash but Yen mark.

スクリーンショット 2022-10-31 125755

スクリーンショット 2022-10-31 125954

When I tried to install tiny-cuda-nn, I got an exception, raise EnvironmentError("Unknown compute capability. Specify the target compute capabilities in the TCNN_CUDA_ARCHITECTURES environment variable or install PyTorch with the CUDA backend to detect it automatically.").

PS D:\stable-dreamfusion> pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
Collecting git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
  Cloning https://github.com/NVlabs/tiny-cuda-nn/ to c:\users\shin\appdata\local\temp\pip-req-build-xqb3iaal
  Running command git clone --filter=blob:none --quiet https://github.com/NVlabs/tiny-cuda-nn/ 'C:\Users\shin\AppData\Local\Temp\pip-req-build-xqb3iaal'
  Resolved https://github.com/NVlabs/tiny-cuda-nn/ to commit c1d2584b50d40dc27e14e39ed9504dab18517f4b
  Running command git submodule update --init --recursive -q
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\shin\AppData\Local\Temp\pip-req-build-xqb3iaal\bindings/torch\setup.py", line 30, in <module>
          raise EnvironmentError("Unknown compute capability. Specify the target compute capabilities in the TCNN_CUDA_ARCHITECTURES environment variable or install PyTorch with the CUDA backend to detect it automatically.")
      OSError: Unknown compute capability. Specify the target compute capabilities in the TCNN_CUDA_ARCHITECTURES environment variable or install PyTorch with the CUDA backend to detect it automatically.
      No CUDA runtime is found, using CUDA_HOME='C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8'
      Building PyTorch extension for tiny-cuda-nn version 1.6
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
y0himba commented 2 years ago

最初にここにアクセスしてください: https://developer.nvidia.com/cuda-gpus#compute

下の表で GPU を調べます。たとえば、私の場合は GeForce RTX 3070 です。CUDA 対応の GeForce および TITAN 製品 をクリックして GPU を見つけると、コンピューターの機能が 8.6 であることがわかります。

これを環境変数に入れる必要があります。確信が持てなかったので、システム セクションとユーザー セクションの両方に入れました。 変数名は TCNN_CUDA_ARCHITECTURES で、変数値は小数点を除いた GPU の数値です。 私のは 8.6 だったので、私の値は 86 です。

次に、管理コマンド プロンプトで refreshenv と入力し、Enter キーを押します。 それでもエラーが発生する場合は、システムを再起動する必要がある場合があります。 image

First go here: https://developer.nvidia.com/cuda-gpus#compute

Look up your GPU in the tables at the bottom, for instance mine is a GeForce RTX 3070, so I click CUDA-Enabled GeForce and TITAN Products, find my GPU, and it shows me my computer capability is 8.6.

You'll need to put this in your environment variables, I put it in both the system and user sections because I wasn't sure. The variable name is TCNN_CUDA_ARCHITECTURES and the variable value is the number for your GPU, without the decimal point. Mine was 8.6, so my value is 86.

Then, in an admin command prompt type refreshenv and hit enter. If you still get the error, you may need to reboot your system.