mirror of
https://github.com/deepseek-ai/Janus.git
synced 2026-11-05 00:57:18 +00:00
[GH-ISSUE #129] The gradio loads but the model does not output anything SOLVED VRAM memory issues SOLVED #99
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/Janus#99
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Zirgite on GitHub (Feb 2, 2025).
Original GitHub issue: https://github.com/deepseek-ai/Janus/issues/129
Microsoft Windows [Version 10.0.19045.5371]
(c) Microsoft Corporation. All rights reserved.
D:\Janus\Janus>myenv\Scripts\activate
(myenv) D:\Janus\Janus>python demo/app_januspro.py
Python version is above 3.10, patching the collections module.
D:\Janus\Janus\myenv\Lib\site-packages\transformers\models\auto\image_processing_auto.py:590: FutureWarning: The image_processor_class argument is deprecated and will be removed in v4.42. Please use
slow_image_processor_class, orfast_image_processor_classinsteadwarnings.warn(
Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████| 2/2 [00:06<00:00, 3.06s/it]
Using a slow image processor as
use_fastis unset and a slow processor was saved with this model.use_fast=Truewill be the default behavior in v4.48, even if the model was saved with a slow processor. This will result in minor differences in outputs. You'll still be able to use a slow processor withuse_fast=False.You are using the default legacy behaviour of the <class 'transformers.models.llama.tokenization_llama_fast.LlamaTokenizerFast'>. This is expected, and simply means that the
legacy(previous) behavior will be used so nothing changes for you. If you want to use the new behaviour, setlegacy=False. This should only be set if you understand what it means, and thoroughly read the reason why this was added as explained in https://github.com/huggingface/transformers/pull/24565 - if you loaded a llama tokenizer from a GGUF file you can ignore this message.Some kwargs in processor config are unused and will not have any effect: ignore_id, add_special_token, image_tag, num_image_tokens, mask_prompt, sft_format.
INFO: Could not find files for the given pattern(s).
To create a public link, set
share=Trueinlaunch().@Zirgite commented on GitHub (Feb 3, 2025):
I have found the solution it is contained here
Tutorial on how to Install and Run the Model on Windows - Not an issue https://github.com/deepseek-ai/Janus/issues/117
but I asked the AI to resume all the steps I made to have it running.
Still after all those efforts the multi-modal was working and not the image creation. The model was consumming 24 gb ov VRAM ans still stalling. So I had to change the script see in the next block
🚀 How to Install and Run Janus-Pro on Windows
This guide provides step-by-step instructions to successfully install and run Janus-Pro on Windows without running into errors.
✅ 1. Install System Dependencies
Before setting up Janus-Pro, ensure you have the following installed:
🔹 Install Microsoft Visual Studio (C++ Build Tools)
🔗 https://visualstudio.microsoft.com/visual-cpp-build-tools/
🔹 Install NVIDIA CUDA Toolkit
🔗 https://developer.nvidia.com/cuda-downloads
🔹 Install Python 3.10+ (if not already installed)
🔗 https://www.python.org/downloads/windows/
✅ 2. Clone the Janus-Pro Repository
Open Command Prompt (CMD) and navigate to your desired installation folder:
Clone the Janus-Pro repository:
Navigate into the cloned directory:
✅ 3. Set Up a Virtual Environment
Create a virtual environment:
Activate the virtual environment:
✅ You should now see
(janus_env)before your command line.✅ 4. Install Required Python Packages
Upgrade pip and install dependencies:
Remove PyTorch from
requirements.txtandpyproject.tomlto prevent CPU installation:requirements.txtand delete any line that installstorch.pyproject.tomland delete any line mentioningtorch.Install Janus-Pro dependencies:
Install Gradio support:
If this fails, install
gradiomanually:✅ 5. Run Janus-Pro
Ensure the virtual environment is activated:
Start Janus-Pro:
✅ If everything is installed correctly, Janus-Pro should now be running! 🚀
❌ Troubleshooting
🔹 "Torch not compiled with CUDA enabled" Error
If you see:
Make sure you manually install PyTorch first before installing requirements:
Then remove
torchfromrequirements.txtandpyproject.toml, then reinstall dependencies:🔹 Virtual Environment Activation Fails
If
activatedoesn’t work in CMD, try using PowerShell:If you see a security error, run this command in Administrator PowerShell:
🔹 Gradio or Transformers Module Not Found
If
gradioortransformersis missing:✅ 6. Automating Virtual Environment Activation
Since the virtual environment must be activated every time before running Janus-Pro, create a startup script.
Windows Batch Script (
start_janus.bat************)Bash Script (
start_janus.sh************) for Git Bash or WSLRun this script whenever you need to start Janus-Pro automatically.
🎯 Final Notes
✔️ Always clone the repository before setting up the virtual environment.
✔️ Manually install PyTorch before other dependencies.
✔️ Remove
torchfromrequirements.txtandpyproject.tomlto prevent CPU-only installation.✔️ Install dependencies in the correct order (install base first, then Gradio).
✔️ Activate the virtual environment before running the script.
✔️ If issues persist, try restarting your PC after installation.
🚀 ! Enjoy!
@Zirgite commented on GitHub (Feb 3, 2025):
I had issues with image generation so I needed to optimize the app_januspro
to be easier on the system.
This solved memory issues and I got the image generation running.
@Zirgite commented on GitHub (Feb 3, 2025):
here is the summirized documentation of the changes
Documentation for VRAM Optimization and Sequential Image Generation in Janus-Pro-7B
This document details the changes made to the image generation component of the Janus-Pro-7B project. Originally, the image generation process used a parallel approach that led to excessive VRAM usage and stalled operations. To resolve this, the code has been refactored to generate images sequentially, thereby reducing memory pressure. The multimodal understanding (chat) functionality remains unaffected.
2. Overview
The primary adjustments include:
Detailed Modifications
3.1. Removed Parallel Generation
Old Function Removed:
The previous version of the generate function that used a parallel_size parameter has been completely removed to avoid naming conflicts and ensure that only the sequential version is active.
3.2. Sequential Image Generation Function
3.3. Updated generate_image Function
3.4. Memory Management
Function Descriptions
4.1. multimodal_understanding
Purpose:
Processes a given image and a text-based question using the Janus-Pro-7B model.
Key Operations:
Sets the seed for reproducibility.
Prepares input embeddings for multimodal understanding.
Generates a response by decoding the output tokens.
Usage:
This function is used for chat-based interactions and remains unchanged.
4.2. generate (Sequential Version)
4.3. generate_image
4.4. unpack
How to Run
Setup:
Ensure you have the required dependencies installed, including Gradio, PyTorch, Transformers, and the Janus libraries.
Launch:
Run the code using your preferred Python interpreter. The Gradio interface will launch, allowing you to interact with both the multimodal chat and image generation functionalities.
Testing:
If VRAM issues persist, reduce the value of num_images (e.g., test with 1 image) or lower the resolution temporarily.
Monitoring:
Monitor your GPU’s memory usage to ensure the new sequential generation method is effectively managing VRAM.
Conclusion
The implemented changes allow the Janus-Pro-7B model to generate images sequentially, significantly reducing VRAM usage compared to the previous parallel method. This solution maintains the multimodal understanding capabilities while ensuring that image generation does not stall due to memory constraints. The code is now more robust and suitable for environments with limited GPU resources.
@aveiper commented on GitHub (Feb 10, 2025):
What an amazing job, I have been struggling with VRAM issues since launch, despite being able to run the deepseek r1 70b model (modestly, but actually running), using an AMD 7900 XTX GPU.
Now, even when working in WSL (where performance is usually worse) I have been able to successfully run the 7b model with a memory usage of 4.5 GB of RAM and about 20 GB of VRAM when generating 1 image at a time.
If someone uses an AMD GPU like me, remember that the model can only run on Linux/WSL environments with the corresponding version of PyTorch installed: https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/native_linux/install-pytorch.html