Torch.backends.cudnn.deterministic: command not found

I am not sure why I am getting these errors:

/var/spool/sge/scc-wm1/job_scripts/5266179: line 1: from: command not found

import: unable to open X server `' @ error/import.c/ImportImageCommand/368.

/var/spool/sge/scc-wm1/job_scripts/5266179: line 3: torch.backends.cudnn.deterministic: command not found

/var/spool/sge/scc-wm1/job_scripts/5266179: line 4: torch.backends.cudnn.benchmark: command not found

/var/spool/sge/scc-wm1/job_scripts/5266179: line 5: syntax error near unexpected token `2809'

/var/spool/sge/scc-wm1/job_scripts/5266179: line 5: `torch.manual_seed(2809)'

I have the following libraries imported in the beginning of my code:

from __future__ import print_function, division

import torch

torch.backends.cudnn.deterministic = True

torch.backends.cudnn.benchmark = False

torch.manual_seed(2809)

from torch.autograd import Variable

import pandas as pd

from PIL import Image

import torch.nn as nn

import torch.optim as optim

from torch.optim import lr_scheduler

import numpy as np

import torchvision

from torchvision import datasets, models, transforms

import matplotlib.pyplot as plt

import time

import os

import copy

import ntpath

from torch.utils.data.sampler import WeightedRandomSampler

import torch.nn.functional as F

Could someone please guide me what’s wrong?

Are you executing the script from the terminal using python or as a shell script? It looks like your machine doesn’t use Python to run it, so you might want to add the shebang at the beginning of your script, e.g.:

#!/usr/bin/env python

I really don’t have any explanation for this but rerunning the job submit on server fixed it without changing anything.