Update inference/infer.py
Browse files67 unmodified lines686970717273747576772 unmodified lines8081828384858687888967 unmodified linesos.makedirs(stage2_output_dir, exist_ok=True)# load tokenizer and model#device = torch.device(f"cuda:{cuda_idx}" if torch.cuda.is_available() else "cpu")# Check if CUDA is availabledevice = torch.device("cuda" if torch.cuda.is_available() else "cpu")# Now you can use `device` to move your tensors or models to the GPU (if available)print(f"Using device: {device}")2 unmodified linesstage1_model,torch_dtype=torch.bfloat16,attn_implementation="flash_attention_2", # To enable flashattn, you have to install flash-attn)# to device, if gpu is availablemodel.to(device)model.eval()codectool = CodecManipulator("xcodec", 0, 1)codectool_stage2 = CodecManipulator("xcodec", 0, 8)67 unmodified lines68697071727374752 unmodified lines7879808182838467 unmodified linesos.makedirs(stage2_output_dir, exist_ok=True)# load tokenizer and modeldevice = torch.device(f"cuda:{cuda_idx}" if torch.cuda.is_available() else "cpu")# Now you can use `device` to move your tensors or models to the GPU (if available)print(f"Using device: {device}")2 unmodified linesstage1_model,torch_dtype=torch.bfloat16,attn_implementation="flash_attention_2", # To enable flashattn, you have to install flash-attn).to(device).eval()codectool = CodecManipulator("xcodec", 0, 1)codectool_stage2 = CodecManipulator("xcodec", 0, 8)
inference/infer.py+2-7