当前位置:网站首页>Accelerating with Dali modules
Accelerating with Dali modules
2022-06-12 23:44:00 【Cheap sword】
Official documents :https://docs.nvidia.com/deeplearning/dali/user-guide/docs/installation.html
One 、 install
TIPS: My version is CUDA 11.4, I installed 11.0 Version of , It doesn't matter
1.cuda10.2
pip install --extra-index-url https://developer.download.nvidia.com/compute/redist --upgrade nvidia-dali-cuda102
2.cuda 11.0
pip install --extra-index-url https://developer.download.nvidia.com/compute/redist --upgrade nvidia-dali-cuda110
Two 、Pipeline
1. Basic use
Pipeline yes DALI Core concepts of module processing data , It's defined in nvidia.dali.Pipeline
(from nvidia.dali.pipeline import Pipeline) in
- Use
pipeline_def
( Official documents ) Decorators are defined- The defined decorator will add multiple parameters . For more parameters, see Official documents .
from nvidia.dali import pipeline_def
import nvidia.dali.fn as fn
import nvidia.dali.types as types
# Just look for some pictures , to images Create several folders , Just put the pictures in the folder
image_dir = "data/images"
max_batch_size = 8
@pipeline_def
def simple_pipeline():
jpegs, labels = fn.readers.file(file_root=image_dir,random_shuffle=True)
#device Of 'mixed' Refers to the use GPU and CPU Hybrid decoding , This is for large resolution JPEG The image is very effective , You can also use only CPU decode
images = fn.decoders.image(jpegs, device='mixed').gpu()
return images, labels
pipe = simple_pipeline(batch_size=max_batch_size, num_threads=1, device_id=0)
pipe.build()
# function , Get one batch Result
pipe_out = pipe.run()
images, labels = pipe_out
The last step , We got the picture and the corresponding tag , The following will images Save as file .labels The value of is passed print(np.array(labels.as_tensor()))
obtain
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
def show_images(image_batch):
columns = 4
rows = (max_batch_size + 1) // (columns)
fig = plt.figure(figsize = (32,(32 // columns) * rows))
gs = gridspec.GridSpec(rows, columns)
for j in range(rows*columns):
plt.subplot(gs[j])
plt.axis("off")
plt.imshow(image_batch.at(j))
plt.savefig("dummy_name.png")
show_images(images.as_cpu())
open dummy_name.png
File to see the picture .
2. Enhancements
Random picture rotation , Fill in the blank 1,( Read more parameters Official documents )
@pipeline_def
def simple_pipeline():
jpegs, labels = fn.readers.file(file_root=image_dir,random_shuffle=True)
images = fn.decoders.image(jpegs, device='mixed').gpu()
angle = fn.random.uniform(range=(-10.0, 10.0))
rotated_images = fn.rotate(images, angle=angle, fill_value=1)
return rotated_images, labels
3. Tips
DALI The module does not support transferring data from within the pipeline GPU Move to CPU in .
3、 ... and 、 Realization
By inheritance Pipeline
Class and rewrite define_graph
Method
Make up later
边栏推荐
- Matters of parent-child class construction method in inheritance
- Divicon est toujours utilisé dans le leaflet de l'ère H5?
- Deep feature synthesis and genetic feature generation, comparison of two automatic feature generation strategies
- Actual combat | inductance element positioning -- detailed explanation of Halcon and opencv implementation (with source code)
- Preparing for the Blue Bridge Cup Day11__ Basic operation of serial port communication
- 2022年G3锅炉水处理考题模拟考试平台操作
- Automatically obtain the position offset of member variables inside the structure
- 1111111111111111111111111111111111111111111111111111111
- Printf segment error (core dump): a problem caused by formatted output
- Restrictions on MySQL function creation
猜你喜欢
Model over fitting - solution (II): dropout
Divicon est toujours utilisé dans le leaflet de l'ère H5?
M_8:设计消息队列存储消息数据的 MySQL 表格
TCP与UDP
Examination questions and online simulation examination for safety management personnel of hazardous chemical business units in 2022
Heilongjiang Branch and Liaoning Branch of PostgreSQL Chinese community have been established!
How does idea switch the interface to Chinese
2202-简历制作
Leetcode 2164. Sort odd and even subscripts separately (yes, once)
Zhengzhou University of light industry -- development and sharing of harmonyos pet health system
随机推荐
M_8:设计消息队列存储消息数据的 MySQL 表格
[opencv learning] small ticket recognition based on perspective transformation and OCR recognition
How to publish OSM maps locally and customize the mapping
Leetcode 2164. 对奇偶下标分别排序(可以,一次过)
自动获取结构体内部成员变量的位置偏移
Bit_ Binary number
Basic operations of dict and set
如何利用华为云容灾解决方案替代灾备一体机
1111111111111111111111111111111111111111111111111111111
[leetcode] understanding and usage of map[key]+
Dry goods sharing | BitSet application details
Industry reshuffle, a large number of programmers are going to lose their jobs? How can we break the current workplace dilemma
cookie
How to get Matplotlib figure size
支持Canvas的Leaflet.Path.DashFlow动态流向线
Common message oriented middleware selection
Huawei cloud elastic ECS use [Huawei cloud to jianzhiyuan]
SAP 业务技术平台(BTP) Workflow(工作流)功能介绍
How about opening a securities account in flush? Is it safe or not
CST learning: four element array design of circular patch antenna (III) array formation and parallel excitation