- 博客(94)
- 收藏
- 关注
原创 pytorch 多GPU训练注意事项
1.多GPU训练记得DataLoader(dataset=dataset_train, batch_size=config['TRAIN']['BATCH'], shuffle=config['TRAIN']['SHUFFLE'], num_workers=config['TRAIN']['WORKERS'],drop_last=True)中的drop_last=True,把最后一块数据丢掉,不然最后报错。2.如果BN在多GPU要同步,那么就要用torch.nn.SyncBatchNorm.conver
2020-12-29 15:55:51
7
原创 pytorch tensorrt torch.nn.functional.conv2d support
https://github.com/LitingLin/torch2trt/commit/9290933aef1507296ddf4923acb47a9ab28c2ae8
2020-12-09 10:24:58
5
原创 pytorch tensorrt Warning: Encountered known unsupported method torch.Tensor.flatten
出现这种错误,首先找到模型的flatten算子,例如x=x.flatten(start_dim=1),改为x=torch.flatten(x,start_dim=1)
2020-12-09 10:21:56
45
原创 ubuntu18.04 pytorch tensorrt安装
1.tensorrt版本:TensorRT-7.2.1.6,链接https://developer.nvidia.com/nvidia-tensorrt-7x-download2.cuda版本:cuda10.2,命令行:wget https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run如果nvdia驱动不匹配的话,重新装一下驱动:a.
2020-12-07 15:39:43
41
1
原创 rk3399 ncnn clang编译和速度优化
rk3399是六个核armV8架构,两个大核,四个小核,ncnn编译的程序,开启两个线程,六个核心一起跑是最快:shufflenet float32:47.12ms(2thread) gcc,g++编译器换成lang,速度优化为:shufflenet float32:47.12ms(2thread) lang,lang++lang的操作如下:(1)sudo apt-get install clang(2)修改ncnn文件下的toolchains/aarch64-linux-gn.
2020-11-23 16:37:18
92
原创 利用taskset,绑定cpu逻辑核心
假如现有一个可执行文件main.so,1.不设置CPU绑定:./main.so2.设置绑定到0号CPU逻辑核心:taskset -c 0 ./bind_core3.设置绑定到0,1号CPU逻辑核心taskset -c 0,1 ./bind_core
2020-11-23 15:29:56
20
原创 linux运行时找不到动态链接库
有时候执行.so文件,例如执行yolov5可执行文件,但找不到某个动态链接库,例如找不到libopencv_highgui.so.3.4:1.首先我们可以执行命令行:ldd yolov5就有提示那些动态链接库找不到,例如提示找不到libopencv_highgui.so.3.42.然后在执行命令行:locate libopencv_highgui.so.3.4就会找到这个文件的路径,例如结果为/home/ubuntu/opencv-3.4.11/build_opencv_armv
2020-11-17 12:16:08
30
原创 rk3399 编译opencv和ncnn,并且利用编译好的ncnn,编译自己的项目
编译opencv1.安装cmake和cmake-gui工具:sudo apt install cmakesudo apt install cmake-gui2.在命令行输入cmake-gui,打开cmake-gui,在where is the source code,输入opencv的项目,在where to build the binaries,输入项目的编译文件build:3.然后点击configure,出现一下的界面:4.选择第三个选项,得到以下的...
2020-11-16 17:46:16
57
转载 docker 跑python 出现UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte
https://blog.csdn.net/u011077672/article/details/70569849
2020-11-09 17:30:09
25
原创 基于python-cuda-nvidia-cudnn的dockerfile模板
基于python-cuda-nvidia-cudnn的dockerfile模板,这里介绍两种gpu的dockerfile模板和一个cpu的dockerfile模板:基于centos(gpu):FROM nvidia/cuda:9.0-cudnn7-devel-centos7MAINTAINER yon@xxxx.comRUN yum -y install make wget \ && wget -O /et
2020-11-08 17:23:17
44
原创 python 跑shell命令行subprocess
import subprocess# s = subprocess.Popen(args='./Text_recognition ../../../test_imgs/1.jpg 640', stdout=subprocess.PIPE,shell=True)import timet1=time.clock()for i in range(1,6): command='./Text_recognition ../../../test_imgs/'+str(i)+'.jpg'+' 640'.
2020-10-23 17:15:16
10
原创 ncnn教程
编写ncnn的C++步骤,基本分为五步:1.定义模型:ncnn:: Net net;2.load模型:#由其他框架例如pytorch,tensorflow转化为ncnn的模型,包括两个文件.param和.binnet.load_param("model.param");net.load_model("model.bin");3.定义输入数据:cv::Mat bgr=cv::imread("path to image");const int target_size = 3.
2020-10-14 12:31:47
108
转载 target_link_libraries 和link_libraries区别
TARGET_LINK_LIBRARIES (设置要链接的库文件的名称)语法:TARGET_LINK_LIBRARIES(targetlibrary1 <debug | optimized> library2 ..)比如(以下写法(包括备注中的)都可以):TARGET_LINK_LIBRARIES(myProject hello),连接libhello.so库TARGET_LINK_LIBRARIES(myProject libhello.a)TARGET_LINK_LIBRARIE.
2020-10-14 09:56:58
131
原创 ubuntu 18.04 安装opencv3.4.11+opencv_contrib
https://blog.csdn.net/qq_33728095/article/details/104256301https://blog.csdn.net/u010739369/article/details/79966263
2020-10-10 19:38:49
60
原创 linux ncnn 编译遇到的问题: Protobuf compiler version doesn‘t match library version 3.7.0
就是说protobuf编译器版本与库版本不匹配。解决方法如下:此时需要在root权限下执行如下:[root@localhostsimple]# vim /etc/ld.so.conf加入:/usr/local/lib之后[root@localhostchensq]#ldconfig[root@localhostchensq]# export LD_LIBRARY_PATH=/usr/local/lib这样之后重新进行cmake..将不会报错;[root@lo...
2020-10-10 17:28:00
464
原创 pybind11 C++ STL和python数据类型的转换
https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html
2020-09-27 15:49:01
127
原创 Ubuntu pybind11教程
1.pybind11的安装:(1)先安装这些第三方库:sudo apt-get install cmake==3.18.2(如果已经安装cmake,可以升级一下cmake:sudo pip install --upgrade cmake==3.18.2)sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ pytest(2)安装pybind11:a.先下载pybind11的源代码:https://github.com.
2020-09-25 16:15:50
430
原创 cython 优化python代码的速度
Cython是一个编程语言,它通过类似Python的语法来编写C扩展并可以被Python调用.既具备了Python快速开发的特点,又可以让代码运行起来像C一样快,同时还可以方便地调用C library。 先举个栗子:四步,(1)新建一个文件helloworld.pyx,编辑代码:def primes(int nb_primes): cdef int n, i, len_p cdef int p[1000] if nb_primes > 1000: ...
2020-09-15 17:13:08
66
原创 pytorch weight init
def weights_init(m): if isinstance(m, nn.Conv2d): nn.init.kaiming_normal_(m.weight) if m.bias is not None: nn.init.constant_(m.bias, 0)model.apply(weight_init)
2020-09-15 11:13:10
15
原创 python logging
def setup_logger(log_file_path: str = None): import logging from colorlog import ColoredFormatter logging.basicConfig(filename=log_file_path, format='%(asctime)s %(levelname)-8s %(filename)s: %(message)s', # 定义输出log的格式.
2020-09-10 21:39:56
35
原创 python ocr text detection 数据增强
def augmentation(im: np.ndarray, text_polys: np.ndarray, scales: np.ndarray, degrees: int, input_size: int) -> tuple: # the images are rescaled with ratio {0.5, 1.0, 2.0, 3.0} randomly im, text_polys = data_aug.random_scale(im, text_polys, scal.
2020-08-26 15:55:38
179
原创 python 判断边框有没有超过图像的长宽并做处理
def check_and_validate_polys(polys, xxx_todo_changeme): ''' check so that the text poly is in the same direction, and also filter some invalid polygons :param polys: :param tags: :return: ''' (h, w) = xxx_todo_changeme .
2020-08-26 15:46:40
107
原创 python logger
def setup_logger(log_file_path: str = None): import logging from colorlog import ColoredFormatter logging.basicConfig(filename=log_file_path, format='%(asctime)s %(levelname)-8s %(filename)s: %(message)s', # 定义输出log的格式.
2020-08-25 16:11:37
68
原创 pytorch 训练学习率warmup
class WarmupMultiStepLR(torch.optim.lr_scheduler._LRScheduler): def __init__( self, optimizer, milestones, gamma=0.1, warmup_factor=1/3, warmup_iters=100, warmup_method="linear", last_epo.
2020-08-25 16:04:36
1236
原创 git fetch的用法
## 在本地新建一个temp分支,并将远程origin仓库的master分支代码下载到本地temp分支;$ git fetch origin master:temp## 比较本地代码与刚刚从远程下载下来的代码的区别;$ git diff temp## 合并temp分支到本地的master分支;$ git merge temp## 如果不想保留temp分支,删除;$ git branch -d temp...
2020-06-05 14:59:52
73
原创 git中的.gitignore不生效的解决方法
两种可能:1.git中的.gitignore要受到跟踪,不然,github不同步,.gitignore就不生效;2.要清空缓存区的内容,缓存区的内容,是不受到.gitignore的约束的,具体命令行如下:git rm -r --cache .git add .git commit -m 'update'...
2020-06-05 14:58:12
53
原创 pycharm调试时出现十分缓慢,变量数据没法预览的解决方法
file->settings->Build,Execution,Deployment->Python Debugger->Gevent compatible
2020-06-03 17:17:52
918
1
原创 pytorch CTCLOSS 降不下來的bug
ctc_loss = nn.CTCLoss()log_probs = torch.randn(50, 16, 20).log_softmax(2)targets = torch.randint(1, 20, (16, 30), dtype=torch.long)input_lengths = torch.full((16,), 50, dtype=torch.long)target_lengths = torch.randint(10,30,(16,), dtype=torch.long)los.
2020-05-26 11:11:26
615
4
原创 pycharm cudnn报错的解决方法
在命令行:sudo gedit ~/.bashrc打开环境配置文件,添加:export LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64done!
2020-05-09 16:45:33
130
原创 ubuntu16.04 install tensorflow 非常稳定快速的安装方式
pip --default-timeout=100 install 库名称 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
2020-05-09 10:33:05
116
原创 ubuntu16.04 install spconv
ubuntu16.04的版本:cuda9.2,g++6.5.0,gcc6.5.0,先保证版本一样,已经试过了别的版本,都不行,只有这个可以。(1)下载spconv源代码:https://github.com/traveller59/spconv(2)下载pybind11:https://github.com/pybind/pybind11(3)解压pybind11,把解...
2020-04-17 14:56:57
1214
2
空空如也
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人 TA的粉丝