Category Archives: Error

[Solved] RuntimeError: An attempt has been made to start a new process before the current process…

When running the Pytorch expression recognition code during hands-on training, the following error occurred:

RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.
 
        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:
 
            if __name__ == '__main__':
                freeze_support()
                ...
 
        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

 

Here is to take multi-threaded tasks, using a single thread to complete, the solution is also very simple, there are the following two.
1. remove the num_workers parameter

 

train_dataloader = torch.utils.data.DataLoader(train_dataset,batch_size=batchsize,shuffle=True,num_workers=0)
val_dataloader = torch.utils.data.DataLoader(val_dataset,batch_size=100,shuffle=False,num_workers=0)

2. Add if __name__=='__main__' before epoch :

if __name__ == '__main__':
    for epoch in range(epochs):
        loss = 0.0
        acc = 0.0
        n = 0
        for image,label in train_dataloader:

Then it can run normally.

VSCode Unable to find custom header file directory: fatal error: no such file or directory

The solution is as follows:

First, add the path of the folder where your header file is located in "includepath":[] of C_cpp_properties.json.

Of course, this step is only to tell the vscode header file where it is for debugging, but it is not known when GCC compiles. We know that if you use G + + main.CPP - I library_path - O main can be compiled successfully directly, so we just need to tell vscode to use our own defined commands

There are generally two methods. The first is to add “- I header_file_path” to the args key in tasks.json, as follows:

	"args": [
		"-g",
		"${workspaceFolder}\\src\\*.cpp",
		"-o",
		"${fileDirname}\\src\\${fileBasenameNoExtension}.exe",
		"-I",
		"header_file_path"
	],

But it doesn’t seem to work well in some cases.

The second method is to directly set in setting.json:

  "code-runner.executorMap": {
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -I 'header_file_path' && $dir$fileNameWithoutExt",
  }

K8s ❉ Error: cannot be handled as a** [How to Solve]

Error Messages:

[root@master ~]# kubectl create -f pod-nginx.yaml 
namespace/dev created
Error from server (BadRequest): error when creating "pod-nginx.yaml": pod in version "v1" cannot be handled as a Pod: no kind "pod" is registered for version "v1" in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:30"

 

 

Solution:

Check the yaml file for the reason as below

apiVersion: v1
kind: pod  # Here it should be Pod, P should be capitalized
metadata:
    name: nginxpod
    namespace: dev
spec:
    containers:
    - name: nginx-containers
      image: nginx:latest

[Solved] ORB_SLAM3 Compile Error: opencv4.0 not found four

CMake Warning at CMakeLists.txt:33 (find_package):
  Could not find a configuration file for package "OpenCV" that is compatible
  with requested version "4.4".

  The following configuration files were considered but not accepted:

    /usr/share/OpenCV/OpenCVConfig.cmake, version: 3.2.0



CMake Error at CMakeLists.txt:35 (message):
  OpenCV > 4.4 not found.


-- Configuring incomplete, errors occurred!
See also "/home/tys/ORB_SLAM3/build/CMakeFiles/CMakeOutput.log".
make: *** No target specified and no makefile found. Stop.

The content of the error report is as above. I found a solution, and there is a solution available.

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

find_package(OpenCV 4.4)
   if(NOT OpenCV_FOUND)
      message(FATAL_ERROR "OpenCV > 4.4 not found.")
   endif()

Find the above location in CMakeList.txt in the ORB_SLAM3 folder and modify

find_package(OpenCV 4.4), as shown in the following code.

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

find_package(OpenCV 3 REQUIRED)
   if(NOT OpenCV_FOUND)
      message(FATAL_ERROR "OpenCV > 4.4 not found.")
   endif()

Normal, so that the fault can be solved.

[Solved] Latex&VScode Error: I found no bibdata command//command//citation—while reading file*.aux

Latex& Vscode error I found no bibdata command// command// citation – while reading file * aux

 

Problem description

The template I use requires the compile order: Compile with: xelatex -> biber -> xelatex -> xelatex

Using various tutorials in the VScode plugin configuration json file are xelatex -> bibtex -> xelatex -> xelatex

In fact bibtex and biber are not a thing, refer to tex link

Resulting in the problem as shown

Solution:

Add the configuration for biber compilation to the setting.json configuration file in VScode’s Latex

 "latex-workshop.latex.tools": [
      
        {
            "name": "biber",
            "command": "biber",
            "args": [
                "%DOC%"
              
            ]
        }
    ],
 "latex-workshop.latex.recipes": [
     {
         "name": "xelatex -> biber -> xelatex*2",
         "tools": [
         "xelatex",
         "biber",
         "xelatex",
         "xelatex"
         ]

     }
 ],

Restart VScode and use xelatex -> biber -> xelatex*2 to compile successfully

Full Codes:

{
    "latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "%DOC%"
            ]
        },
        {
            "name": "xelatex",
            "command": "xelatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "bibtex",
            "command": "bibtex",
            // "command": "biber",
            "args": [
                // "%DOC%"
                "%DOCFILE%"
            ]
        },
        {
            "name": "biber",
            "command": "biber",
            // "command": "biber",
            "args": [
                "%DOC%"
              
            ]
        }
    ],
    "latex-workshop.latex.recipes": [
        {
            "name": "xelatex",
            "tools": ["xelatex"]
        },
        {
            "name": "latexmk",
            "tools": ["latexmk"]
        },
        {
            "name": "pdflatex -> bibtex",
            "tools": ["pdflatex","bibtex"]
        },
        // {
        //     "name": "pdflatex -> bibtex -> pdflatex*2",
        //     "tools": [
        //         "pdflatex",
        //         "bibtex",
        //         "pdflatex",
        //         "pdflatex"
        //     ]
        // },
        {
            "name": "xelatex -> bibtex -> xelatex*2",
            "tools": [
            "xelatex",
            "bibtex",
            "xelatex",
            "xelatex"
            ]

        },
        {
            "name": "xelatex -> biber -> xelatex*2",
            "tools": [
            "xelatex",
            "biber",
            "xelatex",
            "xelatex"
            ]

        }
    ],
    "latex-workshop.latex.clean.fileTypes": [
        "*.aux",
        "*.bbl",
        "*.blg",
        "*.idx",
        "*.ind",
        "*.lof",
        "*.lot",
        "*.out",
        "*.toc",
        "*.acn",
        "*.acr",
        "*.alg",
        "*.glg",
        "*.glo",
        "*.gls",
        "*.ist",
        "*.fls",
        "*.log",
        "*.fdb_latexmk"
    ],
    "latex-workshop.message.error.show": false,
    "latex-workshop.message.warning.show": false,

    "latex-workshop.showContextMenu": true, 
    "latex-workshop.intellisense.package.enabled": true, 
    "latex-workshop.latex.autoBuild.run": "onSave", 

}

[Solved] C# Access Mongodb Database Error: command find failed: Command find requires authentication

The error reports are as follows:

error reason analysis:
literally means that the user name and password authentication are missing, so the database cannot be accessed
solution steps:
1 Add the user name and password to the configuration file connecting to mogondb

run the program again

over