question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: neptune.api_exceptions.SSLError: SSL certificate validation failed

See original GitHub issue

I am unable to log to neptune ai and it showing following error neptune.api_exceptions.SSLError: SSL certificate validation failed. Set NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE environment variable to accept self-signed certificates.

Specs pytorch-lightning==1.5.0
neptune-client==0.13.1
Ubunto 20.04
Python 3.8.10

CODE

class OurModel(LightningModule):
    def __init__(self):
        super(OurModel,self).__init__()
        self.model =  timm.create_model(model_name,pretrained=True)
        self.fc1=nn.Linear(1000,500)
        self.relu=nn.ReLU()
        self.fc2= nn.Linear(500,1)
        #parameters
        self.lr=1e-3
        self.batch_size=72
        self.numworker=18
        self.acc = torchmetrics.Accuracy()
        self.criterion=nn.BCEWithLogitsLoss()

    def forward(self,x):
        x= self.model(x)
        x=self.fc1(x)
        x=self.relu(x)
        x=self.fc2(x)
        return x

    def configure_optimizers(self):
        opt=torch.optim.Adam(params=self.parameters(),lr=self.lr )
        scheduler=CosineAnnealingLR(opt,T_max=10,  eta_min=1e-6, last_epoch=-1)
        return {'optimizer': opt,'lr_scheduler':scheduler}

        
    def train_dataloader(self):
        return DataLoader(DataReader(df_train,aug), batch_size = self.batch_size, 
                          num_workers=self.numworker,pin_memory=True,shuffle=True)

    def training_step(self,batch,batch_idx):
        image,label=batch
        out = self(image).view(-1)
        loss=self.criterion(out,label.float())
        acc=self.acc(out,label.long())
        return {'loss':loss,'acc':acc}

    def training_epoch_end(self, outputs):
        loss=torch.stack([x["loss"] for x in outputs]).mean().detach().cpu().numpy().round(2)
        acc=torch.stack([x["acc"] for x in outputs]).mean().detach().cpu().numpy().round(2)
        self.trainacc.append(acc)
        self.trainloss.append(loss)
        self.log('train_loss', loss)
        self.log('train_acc', acc)
        
    def val_dataloader(self):
        ds=DataLoader(DataReader(df_val,aug), batch_size = self.batch_size,
                      num_workers=self.numworker,pin_memory=True, shuffle=False)
        return ds

    def validation_step(self,batch,batch_idx):
        image,label=batch
        out=self(image).view(-1)
        loss=self.criterion(out,label.float())
        acc=self.acc(out,label.long())
        return {'loss':loss,'acc':acc}

    def validation_epoch_end(self, outputs):
        loss=torch.stack([x["loss"] for x in outputs]).mean().detach().cpu().numpy().round(2)
        acc=torch.stack([x["acc"] for x in outputs]).mean().detach().cpu().numpy().round(2)
        self.valacc.append(acc)
        self.valloss.append(loss)
        print('validation loss accuracy ',self.current_epoch,loss, acc)
        self.log('val_loss', loss)
        self.log('val_acc', acc)



model=OurModel()

from pytorch_lightning.loggers import NeptuneLogger
api_token=
neptune_logger = NeptuneLogger(
    api_key=api_token,
    project="abc/xyz",
    name=model_name, 
    tags=[model_name, save_name],
)

seed_everything(0)

checkpoint_callback = ModelCheckpoint(monitor='val_loss',dirpath='checkpoints',
                                      filename='file',save_last=True)
lr_monitor = LearningRateMonitor(logging_interval='epoch')

trainer = Trainer(max_epochs=50,
                  deterministic=True,
                  gpus=-1,precision=16,
                  accumulate_grad_batches=4,
                  enable_progress_bar = False,
                  callbacks=[checkpoint_callback,lr_monitor],
                  logger=neptune_logger
                  )

trainer.fit(model)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
kamil-kaczmarekcommented, Nov 23, 2021

Ok, got it,

Let me check with our engineering team. We will get back with some insights / more info.

0reactions
Blaizzycommented, Dec 6, 2021

Ok, so I will close this issue and move to that one 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Neptune python gremlin certificate verify failed
I see gremlin console work fine and i can able to run graph query but When i attempt with the python code i...
Read more >
Neptune Exceptions Specific to Individual APIs
This section describes Neptune exceptions raised by individual APIs. ... You may be able to resolve this error by updating your subnet group...
Read more >
DB Cluster Management API Error Messages and Codes
Neptune Service Error Code HTTP status Message MalformedQueryString 404 The query string contains a syntax error. ThrottlingException 400 The request was denied due to request...
Read more >
AWS Neptune SPARQL endpoint certificate expired
The error message you posted shows that the SSL Certificate has expired (since December) which I why I was asking. Add your answer....
Read more >
How to Troubleshoot SSL Certificate & Server Connection ...
Looking for help with the error, “self-signed SSL certificates are being blocked ... Since Postman Console logs all of your API activities, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found