[Question] About the usage of shared memory in docker
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- docker, python
- Lĩnh vực
- distributed-systems, infrastructure
Hướng nghiên cứu
Bắt đầu với trang được liên kết về các hạn chế của bộ nhớ dùng chung trong CycloneDDS, cấu hình XML CYCLONEDDS_URI và các entry point inline của publisher và subscriber. Chạy các container với các tùy chọn network, IPC và volume được hiển thị, sau đó kiểm tra các chẩn đoán được ghi lại và trạng thái bộ nhớ dùng chung; tài liệu được hoàn tất khi giải thích cách xác minh transport và liệu các tiến trình có nên xuất hiện trong ipcs -m hay không.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi,
I'm trying to setup environment and other thins to be able to transfer messages using shared memory. First of all, here is my Image class:
Image class
@dataclass
class MainCameraImage(IdlStruct):
img: array[uint8, 4147200]
shape: array[uint64, 3]
@classmethod
def from_numpy(cls, img):
assert len(img.shape) == 3
seq_img = img.tobytes()
return MainCameraImage(seq_img, tuple(img.shape))
def to_numpy(self):
shape = self.shape
return np.frombuffer(self.img, dtype=np.uint8).reshape(shape)
Note that image array has a fixed size. Then I implement publisher and subscriber:
Publisher
import cv2
import time
import numpy as np
import fire
from cyclonedds.core import Listener, Qos, Policy
from cyclonedds.util import duration
from cyclonedds.internal import dds_infinity
from cyclonedds.domain import DomainParticipant
from cyclonedds.topic import Topic
from cyclonedds.pub import DataWriter
from dds_data_structures import MainCameraImage, Image, CameraState,DeviceState
def stream(dev=0, resize_to=None, output_topic_names=['camera_images', 'camera_images_vis', 'camera_images_clr'],
data_type='MainCameraImage', cap_gstreamer=True):
data_type = MainCameraImage
participant = DomainParticipant(0)
writers = []
# unknown, disabled, enabled, error
qos = Qos(
# livelines: automatic
# deadline: dds_infinity
# reliability: reliable
# durability: volatile
# history: keep last
Policy.Liveliness.Automatic(lease_duration=duration(seconds=10)),
Policy.Deadline(deadline=dds_infinity),
Policy.Reliability.Reliable(max_blocking_time=duration(seconds=1)),
Policy.Durability.Volatile,
Policy.History.KeepLast(1)
)
for topic_name in output_topic_names:
topic_out = Topic(participant, topic_name, data_type)
writers.append(DataWriter(participant, topic_out, qos))
frame = np.random.randint(0, 256, (1280, 1080, 3), dtype=np.uint8)
print(frame.shape, frame.dtype)
while True:
time_start = time.time()
ret, frame = 1, frame
if not ret:
print('Error: Unable to read frame')
break
if resize_to is not None:
frame = cv2.resize(frame, resize_to[::-1])
for writer in writers:
writer.write(data_type.from_numpy(frame))
loop_time = time.time() - time_start
print(f'Streaming Camera with topic {output_topic_names[0]}, {loop_time=}', end='\r')
if __name__ == '__main__':
fire.Fire(stream)
Subscriber
import cv2
import time
import numpy as np
import fire
from cyclonedds.core import Listener, Qos, Policy
from cyclonedds.util import duration
from cyclonedds.internal import dds_infinity
from cyclonedds.domain import DomainParticipant
from cyclonedds.topic import Topic
from cyclonedds.sub import DataReader
from dds_data_structures import MainCameraImage
def receive(topic_name='camera_images'):
data_type = MainCameraImage
participant = DomainParticipant(0)
qos = Qos(
# livelines: automatic
# deadline: dds_infinity
# reliability: reliable
# durability: volatile
# history: keep last
Policy.Liveliness.Automatic(lease_duration=duration(seconds=10)),
Policy.Deadline(deadline=dds_infinity),
Policy.Reliability.Reliable(max_blocking_time=duration(seconds=1)),
Policy.Durability.Volatile,
Policy.History.KeepLast(1)
)
topic_in = Topic(participant, topic_name, data_type)
reader = DataReader(participant, topic_in, qos)
while True:
time_start = time.time()
img = reader.read()
if len(img) == 0:
continue
img = img[0].to_numpy()
loop_time = time.time() - time_start
print(f'Received img {img.shape=}, {loop_time=}', end='\r')
if __name__ == '__main__':
fire.Fire(receive)
I've checked the requirements to the QoS for both publisher and subscriber here (as far as I can see they should be identical).
Next step I'm running iceoryx roudi in one docker container with --net=host --ipc=host -v /dev:/dev -v /tmp:/tmp. I also set the environment variable CYCLONEDDS_URI to the config file. I'm using default config file:
CYclonedds uri config
<?xml version="1.0" encoding="UTF-8" ?>
<CycloneDDS xmlns="https://cdds.io/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://cdds.io/config https://raw.githubusercontent.com/eclipse-cyclonedds/cyclonedds/master/etc/cyclonedds.xsd">
<Domain Id="any">
<General>
<Interfaces>
<NetworkInterface autodetermine="true" priority="default" multicast="default" />
</Interfaces>
<AllowMulticast>default</AllowMulticast>
</General>
<SharedMemory>
<Enable>true</Enable>
<LogLevel>info</LogLevel>
</SharedMemory>
</Domain>
</CycloneDDS>
Finally I run above scripts in the docker containers with the same net and ipc options. They work fine and subscriber receives messages from publisher. What I'm trying to understand:
- How to make sure that messages are being sent via shared memory?
ipcs -mshows only firefox and vs code processes (I've checked pids via `ps -p ). Should my subscriber and publisher be there if everything works as expected?
- Ngôn ngữ chính
- Python
- Star
- 110
- Fork
- 68
- Merge trung bình
- 3 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của eclipse-cyclonedds/cyclonedds-python
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
-
Generated Python code is not interoperable when a union contains a member called "value"Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
eclipse-cyclonedds/cyclonedds-python#333 · 1 bình luận ·
Tất cả issue của eclipse-cyclonedds/cyclonedds-python
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
anchore/grype-db#1149 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: `hermes plugins update` clones an entire monorepo twice - `subdir` is resolved but dropped at both catalog-update call sitesCó thể đã có người làm @HootRock đã nhận hôm nay. Đang mởcomp/cli P2 type/perf
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
NousResearch/hermes-agent#142417 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
SMC SPEC
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
tenstorrent/tt-oca-harness#3287 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug enhancement python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
DewaldOosthuizen/tech-cheat-sheets-and-notes#392 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Critical advisories on mainĐang mởsecurity
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
fabriziosalmi/wildbox#801 ·
Maintainer thường phản hồi trong vòng 1 ngày