docs: document MedGemma CT setup on 3060
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
# MedGemma and CT processing on server 3060
|
||||
|
||||
Date: 2026-11-06
|
||||
|
||||
## Server access
|
||||
|
||||
Server `3060` is reachable from the local Moscow network at `192.168.1.49`.
|
||||
|
||||
SSH access:
|
||||
|
||||
```bash
|
||||
ssh -i ~/.ssh/id_ed25519-3060 naeel@192.168.1.49
|
||||
```
|
||||
|
||||
Windows key path used for the local setup:
|
||||
|
||||
```text
|
||||
Y:\MY\Nubes\id_ed25519
|
||||
```
|
||||
|
||||
The private key itself is not stored in this repository or in this document.
|
||||
|
||||
## Host resources
|
||||
|
||||
Verified on the host:
|
||||
|
||||
- OS: Ubuntu 24.04.5 LTS, x86_64
|
||||
- CPU: AMD Ryzen 5 5600, 6 cores / 12 threads
|
||||
- RAM: 15 GiB
|
||||
- Swap: 4 GiB
|
||||
- GPU: NVIDIA GeForce RTX 3060, 12 GiB VRAM
|
||||
- NVIDIA driver: 580.178.04
|
||||
- Disk: NVMe, 476.9 GB; approximately 141 GB free at verification time
|
||||
|
||||
The host is suitable for local inference with MedGemma 4B. The 27B variants are not a practical fit for this hardware.
|
||||
|
||||
## CT data
|
||||
|
||||
The source CT directory was copied to the host:
|
||||
|
||||
```text
|
||||
/home/naeel/MED_DATA/CY_CT
|
||||
```
|
||||
|
||||
Verification after transfer:
|
||||
|
||||
- 1,669 files
|
||||
- approximately 1.3 GB
|
||||
- source data was not modified
|
||||
|
||||
No DICOM headers, patient identifiers, or image content are stored in this repository.
|
||||
|
||||
## Installed environment
|
||||
|
||||
The isolated Python environment is:
|
||||
|
||||
```text
|
||||
/home/naeel/MED_DATA/medgemma-venv
|
||||
```
|
||||
|
||||
Activate it with:
|
||||
|
||||
```bash
|
||||
source /home/naeel/MED_DATA/medgemma-venv/bin/activate
|
||||
```
|
||||
|
||||
Installed and verified components include:
|
||||
|
||||
- PyTorch `2.11.0+cu128`
|
||||
- Transformers `5.22.1`
|
||||
- torchvision
|
||||
- accelerate
|
||||
- bitsandbytes
|
||||
- huggingface_hub
|
||||
- pydicom
|
||||
- SimpleITK
|
||||
- NumPy
|
||||
- Pillow
|
||||
- safetensors
|
||||
|
||||
CUDA verification succeeded and PyTorch detected the RTX 3060 with 11.60 GiB usable VRAM.
|
||||
|
||||
## MedGemma model
|
||||
|
||||
Model:
|
||||
|
||||
```text
|
||||
google/medgemma-4b-it
|
||||
```
|
||||
|
||||
Local path:
|
||||
|
||||
```text
|
||||
/home/naeel/MED_DATA/models/medgemma-4b-it
|
||||
```
|
||||
|
||||
Model download verification:
|
||||
|
||||
- 15 of 15 files downloaded
|
||||
- approximately 8.64 GB
|
||||
- `AutoProcessor` loaded successfully
|
||||
- `AutoModelForImageTextToText` loaded successfully with BF16 and `device_map="auto"`
|
||||
- model weights loaded on the RTX 3060
|
||||
|
||||
Hugging Face access is gated. The token is stored in the user's Hugging Face cache on the server and is not recorded here. To authenticate a new session, use:
|
||||
|
||||
```bash
|
||||
/home/naeel/MED_DATA/medgemma-venv/bin/hf auth login
|
||||
```
|
||||
|
||||
Do not put the token in this repository, shell history, or chat messages.
|
||||
|
||||
## Smoke test
|
||||
|
||||
A real read-only smoke test was run against one readable DICOM slice from `CY_CT`.
|
||||
|
||||
The test performed the following steps:
|
||||
|
||||
1. Read one DICOM image with `pydicom`.
|
||||
2. Applied `RescaleSlope` and `RescaleIntercept` when present.
|
||||
3. Applied a soft-tissue CT window: center 40, width 400.
|
||||
4. Converted the slice to an 8-bit PIL image.
|
||||
5. Sent one image and a short prompt to MedGemma.
|
||||
|
||||
Result:
|
||||
|
||||
- DICOM found: yes
|
||||
- CUDA inference: successful
|
||||
- elapsed time: approximately 3.5 seconds
|
||||
- response: a generic description of bones, soft tissue, and air; no diagnosis was generated
|
||||
|
||||
This was only a technical inference test. It was not a full-series CT analysis.
|
||||
|
||||
## Correct CT processing pipeline
|
||||
|
||||
MedGemma 4B is an image-text model. It is not a ready-made 3D CT analysis system. The model card describes evaluation primarily on single-image tasks and does not establish reliable multi-image or full-volume CT interpretation.
|
||||
|
||||
A proper pipeline should be:
|
||||
|
||||
```text
|
||||
DICOM series
|
||||
-> group by SeriesInstanceUID
|
||||
-> sort by ImagePositionPatient
|
||||
-> convert pixels to HU
|
||||
-> resample the 3D volume
|
||||
-> apply appropriate CT windows
|
||||
-> run a task-specific 3D CT model
|
||||
-> send selected images and structured results to MedGemma
|
||||
-> save structured output and provenance
|
||||
```
|
||||
|
||||
Useful ready-made components:
|
||||
|
||||
- 3D Slicer for DICOM viewing and volume preparation
|
||||
- TotalSegmentator for anatomical CT segmentation
|
||||
- MONAI Label for interactive model-based segmentation
|
||||
- nnU-Net for a specific segmentation task with a compatible model
|
||||
- OHIF Viewer for browser-based DICOM viewing
|
||||
|
||||
Running all 1,669 files independently through MedGemma would produce disconnected slice descriptions. At the measured rate it would take roughly 1 hour 40 minutes of inference, plus DICOM and output overhead. That is not equivalent to a 3D CT analysis.
|
||||
|
||||
## Current state
|
||||
|
||||
Completed:
|
||||
|
||||
- local SSH access to server 3060 verified
|
||||
- `MED_DATA/CY_CT` copied to the server
|
||||
- isolated GPU Python environment installed
|
||||
- MedGemma 4B downloaded and loaded successfully
|
||||
- one-slice DICOM inference verified
|
||||
|
||||
Not yet implemented:
|
||||
|
||||
- DICOM series grouping and validation
|
||||
- 3D volume assembly and resampling
|
||||
- task-specific CT segmentation or detection model
|
||||
- persistent API or web service
|
||||
- full-series processing and result aggregation
|
||||
|
||||
## Safety and data handling
|
||||
|
||||
The model output is preliminary and may be incorrect. The MedGemma model card requires downstream validation and meaningful adaptation for a specific use case. This repository records installation and engineering checks only; it does not contain a clinical conclusion or patient data.
|
||||
Reference in New Issue
Block a user