svpino / stable-diffusion

13 stars 4 forks source link

Trying to use GPU but get this: (CPU only works) #1

Open Crumb3D opened 2 years ago

Crumb3D commented 2 years ago

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "NVIDIA GeForce GTX 1060 3GB" CUDA Driver Version / Runtime Version 11.8 / 11.8 CUDA Capability Major/Minor version number: 6.1 Total amount of global memory: 3072 MBytes (3220963328 bytes) ( 9) Multiprocessors, (128) CUDA Cores/MP: 1152 CUDA Cores GPU Max Clock rate: 1709 MHz (1.71 GHz) Memory Clock rate: 4004 Mhz Memory Bus Width: 192-bit L2 Cache Size: 1572864 bytes Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384) Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers Total amount of constant memory: zu bytes Total amount of shared memory per block: zu bytes Total number of registers available per block: 65536 Warp size: 32 Maximum number of threads per multiprocessor: 2048 Maximum number of threads per block: 1024 Max dimension size of a thread block (x,y,z): (1024, 1024, 64) Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535) Maximum memory pitch: zu bytes Texture alignment: zu bytes Concurrent copy and kernel execution: Yes with 5 copy engine(s) Run time limit on kernels: Yes Integrated GPU sharing Host Memory: No Support host page-locked memory mapping: Yes Alignment requirement for Surfaces: Yes Device has ECC support: Disabled CUDA Device Driver Mode (TCC or WDDM): WDDM (Windows Display Driver Model) Device supports Unified Addressing (UVA): Yes Device supports Compute Preemption: Yes Supports Cooperative Kernel Launch: Yes Supports MultiDevice Co-op Kernel Launch: No Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0 Compute Mode: < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.8, CUDA Runtime Version = 11.8, NumDevs = 1, Device0 = NVIDIA GeForce GTX 1060 3GB Result = PASS

But get error

Exception has occurred: ResourceExhaustedError Exception encountered when calling layer "res_block_9" (type ResBlock).

in user code:

File "C:\Users\Crumb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\keras_cv\models\generative\stable_diffusion\diffusion_model.py", line 135, in call  *
    x = layer(x)
File "C:\Users\Crumb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler  **
    raise e.with_traceback(filtered_tb) from None

ResourceExhaustedError: Exception encountered when calling layer "padded_conv2d_36" "                 f"(type PaddedConv2D).

in user code:

    File "C:\Users\Crumb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\keras_cv\models\generative\stable_diffusion\__internal__\layers\padded_conv2d.py", line 26, in call  *
        return self.conv2d(x)
    File "C:\Users\Crumb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler  **
        raise e.with_traceback(filtered_tb) from None
    File "C:\Users\Crumb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\keras\backend.py", line 2100, in random_uniform
        return tf.random.stateless_uniform(

    ResourceExhaustedError: {{function_node __wrapped__Mul_device_/job:localhost/replica:0/task:0/device:GPU:0}} failed to allocate memory [Op:Mul]

Call arguments received by layer "padded_conv2d_36" "                 f"(type PaddedConv2D):
  • inputs=tf.Tensor(shape=(None, 6, 6, 1280), dtype=float32)

Call arguments received by layer "res_block_9" (type ResBlock): • inputs=['tf.Tensor(shape=(None, 6, 6, 1280), dtype=float32)', 'tf.Tensor(shape=(None, 1280), dtype=float32)']

During handling of the above exception, another exception occurred:

File "C:\Users\Crumb\AppData\Local\Temp__autograph_generated_filej7bnq6_q.py", line 13, in tfcall retval_ = ag__.converted_call(ag.ld(self).conv2d, (ag__.ld(x),), None, fscope)

During handling of the above exception, another exception occurred:

During handling of the above exception, another exception occurred:

File "C:\Users\Crumb\AppData\Local\Temp__autograph_generated_file12f33m7g.py", line 25, in tfcall ag.for_stmt(ag.ld(self).entry_flow, None, loop_body, get_state, set_state, ('x',), {'iterate_names': 'layer'}) File "C:\Users\Crumb\AppData\Local\Temp__autograph_generated_file12f33m7g.py", line 23, in loop_body x = ag.converted_call(ag.ld(layer), (ag.ld(x),), None, fscope)

During handling of the above exception, another exception occurred:

During handling of the above exception, another exception occurred:

File "O:\python\test.py", line 51, in model = keras_cv.models.StableDiffusion(

however if i comment out the dlls part so it doesnt use GPU, it works a treat just slow

Crumb3D commented 2 years ago

Any ideas?

svpino commented 2 years ago

Hey @Crumb3D, ResourceExhaustedError usually happens when there's no GPU memory available to schedule a task.

My recommendation is two-fold:

  1. How many images are you trying to generate at once? Can you try and reduce that and see if it helps?
  2. If it doesn't work, I'd recommend you report this on the Keras_CV repository.