Tag Archives: ProgrammerAH

[Solved] RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`

Today, I encountered a speechless mistake and tossed it for a long time… I mentioned the feature network with Bert, but it didn’t work… I checked the size and found that it wasn’t, and later found that it wasn’t on CUDA

Specific error reporting

RuntimeError: Caught RuntimeError in replica 0 on device 0.
RuntimeError: CUDA error: CUBLAS_ STATUS_ ALLOC_ FAILED when calling `cublasCreate(handle)

resolvent:

ext_hashCodes.unsqueeze(1).repeat(1, B, 1)
#change to
ext_hashCodes.unsqueeze(1).repeat(1, B, 1).cuda()
#It's OK

[Solved] SyntaxError: Missing parentheses in call to ‘print‘. Did you mean print(e)?

After learning the fourth lesson of Mr. Gu Yue’s ROS, I started the keyboard control of the robot and reported this error in the launch file. The following is the error content:

process[mbot_teleop-1]: started with pid [4942]
  File "/home/zxf/catkin_ws/src/mbot_teleop/scripts/mbot_teleop.py", line 78
    print msg
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(msg)?
[mbot_teleop-1] process has died [pid 4942, exit code 1, cmd /home/zxf/catkin_ws/src/mbot_teleop/scripts/mbot_teleop.py __name:=mbot_teleop __log:=/home/zxf/.ros/log/4e9341ca-0155-11ec-8ec5-cf95496c0738/mbot_teleop-1.log].
log file: /home/zxf/.ros/log/4e9341ca-0155-11ec-8ec5-cf95496c0738/mbot_teleop-1*.log

I searched the Internet and found that it was because of the version of python2. X was incompatible with the version of python3. X. The reason for the error lies in the print output syntax. A simple example is hello ROS

python2.x
print "hello ROS"     
Output: hello ROS
print 'hello ROS'
Output: hello ROS
print ('hello ROS')
Output: hello ROS
print ("hello ROS")
Output: hello ROS

The above four methods can be applied in Python 2. X, but not necessarily in Python 3. X

python3.x
print("hello ROS")
Output: hello ROS
print(hello ROS)
Output: hello ROS

I use Ubuntu 20.04, so it is the Python 3 version, which is different from that used by Gu Yue, so I need to modify ~/catkin_ws/src/mbot_teleop/scripts/mbot_ Teleop.py file

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import rospy
from geometry_msgs.msg import Twist
import sys, select, termios, tty

msg = """
Control mbot!
---------------------------
Moving around:
   u    i    o
   j    k    l
   m    ,    .

q/z : increase/decrease max speeds by 10%
w/x : increase/decrease only linear speed by 10%
e/c : increase/decrease only angular speed by 10%
space key, k : force stop
anything else : stop smoothly

CTRL-C to quit
"""

moveBindings = {
        'i':(1,0),
        'o':(1,-1),
        'j':(0,1),
        'l':(0,-1),
        'u':(1,1),
        ',':(-1,0),
        '.':(-1,1),
        'm':(-1,-1),
           }

speedBindings={
        'q':(1.1,1.1),
        'z':(.9,.9),
        'w':(1.1,1),
        'x':(.9,1),
        'e':(1,1.1),
        'c':(1,.9),
          }

def getKey():
    tty.setraw(sys.stdin.fileno())
    rlist, _, _ = select.select([sys.stdin], [], [], 0.1)
    if rlist:
        key = sys.stdin.read(1)
    else:
        key = ''

    termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)
    return key

speed = .2
turn = 1

def vels(speed,turn):
    return "currently:\tspeed %s\tturn %s " % (speed,turn)

if __name__=="__main__":
    settings = termios.tcgetattr(sys.stdin)
    
    rospy.init_node('mbot_teleop')
    pub = rospy.Publisher('/cmd_vel', Twist, queue_size=5)

    x = 0
    th = 0
    status = 0
    count = 0
    acc = 0.1
    target_speed = 0
    target_turn = 0
    control_speed = 0
    control_turn = 0
    try:
        print(msg)
        print(vels(speed,turn))
        while(1):
            key = getKey()
            if key in moveBindings.keys():
                x = moveBindings[key][0]
                th = moveBindings[key][1]
                count = 0
            elif key in speedBindings.keys():
                speed = speed * speedBindings[key][0] 
                turn = turn * speedBindings[key][1]   
                count = 0

                print(vels(speed,turn))
                if (status == 14):
                    print(msg)
                status = (status + 1) % 15
            elif key == ' ' or key == 'k' :
                x = 0
                th = 0
                control_speed = 0
                control_turn = 0
            else:
                count = count + 1
                if count > 4:
                    x = 0
                    th = 0
                if (key == '\x03'):
                    break

            target_speed = speed * x
            target_turn = turn * th

            if target_speed > control_speed:
                control_speed = min( target_speed, control_speed + 0.02 )
            elif target_speed < control_speed:
                control_speed = max( target_speed, control_speed - 0.02 )
            else:
                control_speed = target_speed

            if target_turn > control_turn:
                control_turn = min( target_turn, control_turn + 0.1 )
            elif target_turn < control_turn:
                control_turn = max( target_turn, control_turn - 0.1 )
            else:
                control_turn = target_turn

            twist = Twist()
            twist.linear.x = control_speed; 
            twist.linear.y = 0; 
            twist.linear.z = 0
            twist.angular.x = 0; 
            twist.angular.y = 0; 
            twist.angular.z = control_turn
            pub.publish(twist)

    except:
        print(e)

    finally:
        twist = Twist()
        twist.linear.x = 0; twist.linear.y = 0; twist.linear.z = 0
        twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = 0
        pub.publish(twist)

    termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)

It is probably to add () to the print output statement on lines 78, 79, 93, 95 and 141.

Linux Error: bind error: Address already in use [How to Solve]

About network programming, the server-client bind error: address already in use:

reason:

1. You used the port number, but the process did not exist.

2. At the end of the process:

crtl +c   And crtl + Z are different. The former ends the process and the latter suspends the process

If you use the latter, the process will hang and not be killed

 

Solution:

1. Kill the process

PS – Aue view PID   , Then kill + process PID and kill the process

2. Change the port number

3. Wait half a minute until the port is released

4. External parameter transmission

It is more convenient to directly change the new port number than 2

5. Use the setsockopt() function to cancel the port number binding restriction

int on=1;
setsockopt(fd,SOL_ SOCKET,SO_ REUSEADDR,& on,sizeof(on));

[Solved] error: RPC failed; curl 56 GnuTLS recv error (-110): The TLS connection was non-properly terminated.

mkdir ~/.git-rectify    (. stands for hidden)
        1. mkdir ~/.git-rectify (. stands for hidden)

      cd ~/git-rectify

 

        1. apt-get source gitsudo apt-get build-dep gitsudo apt-get install libcurl4-openssl-devcd git-2.17.1/vim ./debian/control #modify

      libcurl4-gnutls-dev to libcurl4-openssl-dev

 

    1. vim ./debian/rules # Delete sudo dpkg-buildpackage -rfakeroot -bcd …

 

    1. sudo dpkg -i git_2.17.1-1ubuntu0.4_amd64.deb

 

[Solved] RuntimeError: Error(s) in loading state_dict for FasterRCNN: Missing key(s) in state_dict:……

Problem description
RuntimeError: Error(s) in loading state_dict for FasterRCNN:Missing key(s) in state_dict: “backbone.body.conv1.weight”, “backbone.body.bn1.weight”, …

Solution:

# model.load_state_dict(torch.load("./model.pth"))
model.load_state_dict(torch.load("./model.pth"), False)

Source code analysis

load_state_dict(state_dict, strict=True)[SOURCE]
		Copies parameters and buffers from state_dict into this module and its descendants. If strict is True, then the keys of state_dict must exactly match the keys returned by this module’s state_dict() function.

		Parameters
			state_dict (dict) – a dict containing parameters and persistent buffers.

			strict (bool, optional) – whether to strictly enforce that the keys in state_dict match the keys returned by this module’s state_dict() function. Default: True

		Returns
			missing_keys is a list of str containing the missing keys

			unexpected_keys is a list of str containing the unexpected keys

		Return type
			NamedTuple with missing_keys and unexpected_keys fields

Pyinstall (Unicode error) ‘Unicode scape’ error handling

Syntax Error:

Enabled

old

The following means: pathex=[‘F:\wk\hangye\oracletab’],
& & & & & & & & & & & & & & & & binaries=[],
& & & & & & & & & & & xls=[(‘F:\wk\hangye\oracletab\\sql’,’sql’),(‘F:\wk\hangye\oracletab\\xls’,’xls’),(‘F:\wk\hangye\oracletab\\temp’,’temp’),(‘F:\wk\hangye\oracletab\\xls’,’xls’),(‘),(‘F:\wk\hangye\oracletab\\shell’,’shell’),(‘F:\wk\hangye\oracletab\\instantclient_11_2′,’.’), (‘F:\wk\hangye\oracletab\\moban’,’.’)],
         ➣ ➣ mports=[],

_Attributes

   pathex=[‘F:\\wk\\hangye\\xinyibaotab’],
             binaries=[],
             datas=[(‘F:\\wk\hangye\\xinyibaotab\\sql’,’sql’),(‘F:\\wk\\hangye\\xinyibaotab\\xls’,’xls’),(‘F:\\wk\\hangye\\xinyibaotab\\temp’,’temp’),(‘F:\\wk\\hangye\\xinyibaotab\\shell’,’shell’),(‘F:\\wk\\hangye\\xinyibaotab\\moban’,’.’)],
       hydrodenimports=[],

**Gazebo error – [REST.cc:205] Error in REST request**

Gazebo error – [rest. CC: 205] error in rest request
summarize some problems encountered in today’s running navigation
this error message appears. Gazebo error – [rest. CC: 205] error in rest request is probably due to the problem in the following file
~ /. Ignition/fuel/config.yaml
put the
URL: https://api.ignitionfuel.org Use URL: https://api.ignitionrobotics.org replace ~ /. Ignition/fuel/config.yaml file.

After changing this file, there may be errors, but it will not affect the use
the reason is that we just changed the above file
for the problem we want to solve, we can refer to the following scheme
error code

[Err] [ClientConfig.cc:270] Parser error [4]

Ignore the error, as it doesn’t affect functionality.
Delete the configuration file ~/.ignition/fuel/config.yaml, which may be broken. The next time you launch Gazebo a new file should be created.

npm run devstart error: Error: Unable to find module ‘semver’

PS C:\Users\wangting\Desktop\Wisdom_admin\wisdom_admin> npm run dev

> [email protected] dev C:\Users\wangting\Desktop\Wisdom_admin\wisdom_admin
> vue-cli-service serve

internal/modules/cjs/loader.js:985
  throw err;
  ^

Error: Cannot find module 'semver'
Require stack:
- C:\Users\wangting\Desktop\Wisdom_admin\wisdom_admin\node_modules\_@[email protected]@@vue\cli-service\bin\vue-cli-service.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (C:\Users\wangting\Desktop\Wisdom_admin\wisdom_admin\node_modules\_@[email protected]@@vue\cli-service\bin\vue-cli-service.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\wangting\\Desktop\\Wisdom_admin\\wisdom_admin\\node_modules\\_@[email protected]@@vue\\cli-service\\bin\\vue-cli-service.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1        
npm ERR! [email protected] dev: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\wangting\AppData\Roaming\npm-cache\_logs\2021-08-06T06_20_38_961Z-debug.log
PS C:\Users\wangting\Desktop\Wisdom_admin\wisdom_admin> 

In case of such an error
you need to

Delete node_ modules

Then open the vscode editor, open the terminal, enter the project directory, and install the dependencies

cnpm install

After dependency installation is complete

Just start it again

Restart

npm run dev

You’ll find it working normally


[Solved] TypeError: Cannot read property ‘indexOf‘ of undefined at VueComponent.resetFields

When you click the empty form button, an error will be reported because the form contains values that are not found;

For example, when active = 1, the prop of El form item is bound to username; When active = 2, prop binds gender;

When active = 1, the form contains username and gender, and gender is not displayed on the page. When the form is cleared, all values in the form will be cleared, and the gender field cannot be found, so an error is reported;

 

Solution:

Replace the resetfields provided with element with each item in the form as the initial value;

For example:

reset(formName){
this.form.username='',
this.form.gender=''
  this.$nextTick(() => {
        this.$refs[formName].clearValidate(); //To clear the checksum prompt
      
      });
}

Android studio reports an error when running the main() method

1.Error Content.
SourceSet with name ‘main’ not found
Solution.
In the gradle.xml file in the .idea folder add
<option name="delegatedBuild" value="false" />
2. Error reporting:
Command line is too long. Shorten command line for ServiceStarter or also for Application default configuration.
Solution:
In the workspace.xml file in the .idea folder, find the tag
<component name=”PropertiesComponent”>, add a line to the tag
<property name=”dynamic.classpath” value=”true” />