閱讀542 返回首頁    go 阿裏雲 go 技術社區[雲棲]


F1 RTL使用教程

[TOC]

1. 配置基礎環境

1. 安裝依賴軟件

使用 SSH 登陸到服務器;安裝基礎環境。

yum install -y python-devel screen
pip install aliyun-python-sdk-ram
pip install aliyun-python-sdk-faas
pip install oss2

隨後,使用 vim 編輯/usr/lib/python2.7/site3packages/aliyunsdkcore/endpoints.xml

在第 648 行下添加一行代碼

<Product><ProductName>faas</ProductName><DomainName>faas.cn3hangzhou.aliyuncs.com</DomainName></Product>

接下來,安裝 faascmd 腳本

vi /usr/local/bin/faascmd

將代碼粘貼進入後,保存退出,執行如下代碼

chmod a+x /usr/local/bin/faascmd

放在 /usr/local/bin 下可以直接執行 faascmd 命令,而無需加入前方的路徑

2. 配置 DCP 環境

screen -S aliyunfaas
cd /opt/dcp1_0/script
sh install_sdk.sh

3. 配置環境變量

sh ini_driver.sh
source intel_fpga_env.sh
source intel_quartus_env.sh export PATH=$PATH:/opt/dcp1_0/bin

2. 編譯工程

cd /opt/dcp1_0/hw/green_bits/dma_afu/src 
run.sh

PS. 此處編譯時間很長

3. 製作鏡像

1. 初始化 faascmd

首先,需要初始化faascmd

# 將 hereIsMySecretId 換為你的OSS SecretID,hereIsMySecretKey 換為你的 OSS 的SecretKey
faascmd config --id=hereIsMySecretId --key=hereIsMySecretKey
# 將hereIsMyBucket換為華東1區的OSS的 Bucket 名
faascmd auth --bucket=hereIsMyBucket

2. 上傳 gbs 文件

完成上述操作後,直接執行如下代碼,此時你應該還在/opt/dcp1_0/hw/green_bits/dma_afu/src 目錄下

faascmd upload_object --object=dma_afu.gbs --file=dma_afu.gbs

3. 製作鏡像

#  將 hereIsYourImageName 替換為 你的鏡像名
faascmd create_image --object=dma_afu.gbs --fpgatype=intel --name=hereIsYourImageName  --tags=hereIsYourImageTag --encrypted=false --shell =V1.0

4. 下載鏡像

1. 檢查鏡像是否已經生成完成。

faascmd list_images

當看到狀態為 Success 時,說明鏡像生成成功

2. 獲取 FPGA UUID

# 將 hereIsYourInstanceId 替換為你的 FPGA 雲服務器的實例 ID 
faascmd list_instances --instanceId=hereIsYourInstanceId


這裏記下 FpgaUUID

實例ID 可以在 FPGA 雲服務器詳情頁獲取

3. 下載 FPGA 鏡像

執行命令下載鏡像

下載鏡像到本地

# 將 hereIsYourInstanceID 替換為剛剛保存的實例ID;將 hereIsFpgaUUID 替換為上一條命令中記下的 FpgaUUID;將 hereIsImageUUID 替換為上一步記下的 FpgaImageUUID
faascmd download_image  --instanceId=hereIsYourInstanceID --fpgauuid=hereIsFpgaUUID --fpgatype=intel --imageuuid=hereIsImageUUID --imagetype=afu --shell=V1.0

當你看到這樣的字樣,說明下載成功

也可以執行命令查看

# 將 hereIsYourInstanceID 替換為剛剛保存的實例ID;將 hereIsFpgaUUID 替換為上一條命令中記下的 FpgaUUID;
faascmd fpga_status  --instanceId=hereIsYourInstanceID --fpgauuid=hereIsFpgaUUID 

當你看到 TaskStatus 為 Valid 時,且 FpgaImageUUID 和下載鏡像時的FpgaImageUUID一致,則說明下載正常

4. 測試

在命令行中執行

cd /opt/dcp1_0/hw/green_bits/dma_afu/src/sw
make
./fpga_dma_test use_ase=0

你會看到這樣的輸出,說明測試完成

PS:如果沒有開啟大頁:

sudo bash -c "echo 20 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages"

最後更新:2017-10-27 16:04:12

  上一篇:go  【專欄】穀歌資深工程師深入淺析AlphaGo Zero與深度強化學習
  下一篇:go  F1 OpenCL使用教程