Troubleshooting DeepPurpose
Fix DeepPurpose installs, DGL and RDKit imports, CUDA device errors, out-of-memory training runs, SMILES parsing failures and diverging loss or NaNs.
DeepPurpose is a deep learning library for drug-target interaction (DTI) prediction. This guide covers common issues and their solutions.
Installation issues
ModuleNotFoundError: No module named 'DeepPurpose'
Install DeepPurpose from pip or GitHub:
ImportError: DGL backend not set
For GNN encoders (MPNN, DGL_*), install DGL:
RDKit import errors
RDKit is required for molecular processing:
Common issues
CUDA error: invalid device ordinal
Match torch to your CUDA runtime (e.g., cu121) and confirm torch.cuda.device_count() > 0. Set CUDA_VISIBLE_DEVICES if the job exposes multiple GPUs.
OOM (Out of Memory) during training
Lower batch_size, shorten sequences (truncate SMILES/FASTA), and use simpler encoders to reduce memory:
- Switch from Transformer to CNN encoders
- Switch from GNN (MPNN, DGL_*) to fingerprint encoders (Morgan, Pubchem)
- Reduce
cls_hidden_dimslayer sizes - Set
train_epochlower and use early stopping
Data parsing errors
Validate CSV columns (smiles, protein, affinity or task-specific labels). Remove empty strings and canonicalize SMILES before featurization:
Diverging loss / NaNs
Reduce learning rate, disable weight decay for small datasets, and verify labels are scaled correctly for regression vs. classification tasks:
- For binding affinity regression, use log-transformed values (pKd, pKi)
- Ensure labels are in reasonable range (e.g., 0-15 for pKd)
- Start with
LR=0.0001and increase gradually
Encoder-specific issues
GNN encoders fail on some molecules
Some molecules may fail graph construction:
Transformer encoder slow on long sequences
Transformer attention scales quadratically with sequence length. For long proteins:
- Truncate sequences to max ~1000 amino acids
- Use CNN encoder for long proteins
- Consider domain-based splitting for multi-domain proteins
Pretrained encoder loading fails
Ensure you have the correct encoder name:
Logging checklist
- Log DeepPurpose and torch versions, CUDA availability, and GPU name.
- Capture the exact encoders used (
drug_encoding,target_encoding). - Record dataset split fractions and random seeds.
- Save a sample batch (first 5 rows) to
outputs/sample_batch.csvfor debugging.
When to retry vs. stop
- Retry: transient CUDA initialization failures or intermittent filesystem errors.
- Stop and fix: missing columns, incompatible torch/CUDA versions, or consistent NaNs after lowering LR.
Getting help
If issues persist:
- Check the DeepPurpose GitHub Issues
- Reference the Bioinformatics paper for methodology details
- Ensure you're using compatible versions:
- Python 3.7+
- PyTorch 1.7+
- RDKit 2020+
- DGL 0.5+ (for GNN encoders)
Read next
Was this page helpful?