Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AttributeError when accessing profile_idx of NoneType #259

Merged
merged 1 commit into from
Feb 5, 2024

Conversation

shinshin86
Copy link
Contributor

This PR addresses an issue that was causing an AttributeError when trying to access the profile_idx attribute of sd_unet.current_unet, which was None.

The error was as follows:

*** Error running process_batch: C:\Users\uesrname\stable-diffusion-webui\extensions\Stable-Diffusion-WebUI-TensorRT\scripts\trt.py
    Traceback (most recent call last):
      File "C:\Users\username\stable-diffusion-webui\modules\scripts.py", line 742, in process_batch
        script.process_batch(p, *script_args, **kwargs)
      File "C:\Users\username\stable-diffusion-webui\extensions\Stable-Diffusion-WebUI-TensorRT\scripts\trt.py", line 302, in process_batch
        if self.idx != sd_unet.current_unet.profile_idx:
    AttributeError: 'NoneType' object has no attribute 'profile_idx'

This error occurred when sd_unet.current_unet was None. Trying to reference sd_unet.current_unet.profile_idx resulted in an AttributeError because the NoneType object does not have a profile_idx attribute.

To fix this issue, I added a condition to check if sd_unet.current_unet is not None before trying to access its profile_idx attribute. This prevents the AttributeError from being raised when sd_unet.current_unet is None.

Please review this fix and let me know if there are any issues or further changes needed.

@CaptainVarghoss
Copy link

Thanks for this, got tired of seeing that stupid error for the last month and came looking for a fix.

@contentis contentis changed the base branch from main to dev February 5, 2024 08:34
@contentis contentis merged commit 7ba0324 into NVIDIA:dev Feb 5, 2024
@shinshin86 shinshin86 deleted the fix-process_batch-error branch February 5, 2024 13:12
contentis added a commit that referenced this pull request Mar 13, 2024
* fix typo (#79)

* Faster and simplified install

* Print correct profile when engine is loaded

* Use scripts callbacks

* increase max resolution

* adding native LoRA support, avoiding model.py import error and some refactoring

* more refactoring and added typing

* Enable torch fallback

* update inastall

* change default XL engine

* cc independent lora

* Update Instrucitons

* Fix for #225 Install.py silently blocked by blocking call of nvidia-cudnn-cu11 uninstall due to interactive python shell opening (#226)

* v0.2.0 (#217)

* fix typo (#79)

* Print correct profile when engine is loaded

* Use scripts callbacks

* increase max resolution

* adding native LoRA support, avoiding model.py import error and some refactoring

* more refactoring and added typing

* Enable torch fallback

* update inastall

* change default XL engine

* cc independent lora

* Update Instrucitons

---------

Co-authored-by: Rudra <92840555+Rudra-Ji@users.noreply.github.com>

* Fix subprocess blocking issue when installing

---------

Co-authored-by: Luca <lspindler@nvidia.com>
Co-authored-by: Rudra <92840555+Rudra-Ji@users.noreply.github.com>

* Resolve AttributeError on generation without Unet (#224)

* v0.2.0 (#217)

* fix typo (#79)

* Print correct profile when engine is loaded

* Use scripts callbacks

* increase max resolution

* adding native LoRA support, avoiding model.py import error and some refactoring

* more refactoring and added typing

* Enable torch fallback

* update inastall

* change default XL engine

* cc independent lora

* Update Instrucitons

---------

Co-authored-by: Rudra <92840555+Rudra-Ji@users.noreply.github.com>

* Resolve AttributeError on generation without Unet

---------

Co-authored-by: Luca <lspindler@nvidia.com>
Co-authored-by: Rudra <92840555+Rudra-Ji@users.noreply.github.com>

* Fixes crashes cause by lora checkpoint configs missing sd version (#251)

During the initial Lora loading process, if a config for a specified **.safetensor** file does not contain the property **"sd version"**, the plugin crashes and does not show the trt tab. 

fixes the issue by inferencing the model version as unknown

* Fix AttributeError when accessing profile_idx of NoneType (#259)

* fix #157

---------

Co-authored-by: Rudra <92840555+Rudra-Ji@users.noreply.github.com>
Co-authored-by: Andrew Vuong <andrewtvuong@utexas.edu>
Co-authored-by: Aether <59086566+AetherMagee@users.noreply.github.com>
Co-authored-by: ZN <72399198+Zn10plays@users.noreply.github.com>
Co-authored-by: Yuki Shindo <shinshin86@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants